Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TargetPath.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Fixture\DataSource;
10 use Magento\Mtf\Fixture\FixtureFactory;
11 use Magento\Mtf\Fixture\FixtureInterface;
12 
16 class TargetPath extends DataSource
17 {
23  protected $entity = null;
24 
31  public function __construct(FixtureFactory $fixtureFactory, array $params, $data = '')
32  {
33  $this->params = $params;
34  if (!isset($data['entity']) || $data['entity'] === '-') {
35  $this->data = $data;
36  return;
37  }
38  preg_match('`%(.*?)%`', $data['entity'], $dataset);
39  $entityConfig = isset($dataset[1]) ? explode('::', $dataset[1]) : [];
40  if (count($entityConfig) > 1) {
42  $this->entity = $fixtureFactory->createByCode($entityConfig[0], ['dataset' => $entityConfig[1]]);
43  $this->entity->persist();
44  $id = $this->entity->hasData('id') ? $this->entity->getId() : $this->entity->getPageId();
45  $this->data = preg_replace('`(%.*?%)`', $id, $data['entity']);
46  } else {
47  $this->data = (string)$data['entity'];
48  }
49  }
50 
56  public function getEntity()
57  {
58  return $this->entity;
59  }
60 }
$id
Definition: fieldset.phtml:14
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18