Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
WebsiteId.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Fixture\DataSource;
10 use Magento\Mtf\Fixture\FixtureFactory;
12 use Magento\Store\Test\Fixture\Website;
13 
17 class WebsiteId extends DataSource
18 {
24  private $store;
25 
31  private $website;
32 
38  private $fixtureFactory;
39 
45  private $fixtureData = null;
46 
53  public function __construct(
54  FixtureFactory $fixtureFactory,
55  array $params,
56  $data = []
57  ) {
58  $this->fixtureFactory = $fixtureFactory;
59  $this->params = $params;
60  $this->fixtureData = $data;
61  }
62 
70  public function getData($key = null)
71  {
72  if (empty($this->fixtureData)) {
73  throw new \Exception("Data must be set");
74  }
75 
76  if (isset($this->fixtureData['website'])) {
77  $this->website = $this->fixtureData['website'];
78  $this->data = $this->fixtureData['website']->getName();
79  } else {
80  if (isset($this->fixtureData['dataset'])) {
81  $store = $this->fixtureFactory->createByCode('store', $this->fixtureData);
82 
83  if (!$store->getStoreId()) {
84  $store->persist();
85  }
86 
87  $website = $store->getDataFieldConfig('group_id')['source']
88  ->getStoreGroup()->getDataFieldConfig('website_id')['source']->getWebsite();
89 
90  $this->data = $website->getName();
91  $this->website = $website;
92  $this->store = $store;
93  }
94  }
95 
96  return parent::getData($key);
97  }
98 
104  public function getStore()
105  {
106  return $this->store;
107  }
108 
114  public function getWebsite()
115  {
116  return $this->website;
117  }
118 }
__construct(FixtureFactory $fixtureFactory, array $params, $data=[])
Definition: WebsiteId.php:53
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18