예제 #1
0
파일: IdPath.php 프로젝트: aiesh/magento2
 /**
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data [optional]
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (!isset($data['entity']) || $data['entity'] === '-') {
         $this->data = array_shift($data);
         return;
     }
     preg_match('`%(.*?)%`', $data['entity'], $dataSet);
     $entityConfig = isset($dataSet[1]) ? explode('::', $dataSet[1]) : [];
     if (count($entityConfig) > 1) {
         /** @var FixtureInterface $fixture */
         $this->entity = $fixtureFactory->createByCode($entityConfig[0], ['dataSet' => $entityConfig[1]]);
         $this->entity->persist();
         $id = $this->entity->hasData('id') ? $this->entity->getId() : $this->entity->getPageId();
         $this->data = preg_replace('`(%.*?%)`', $id, $data['entity']);
     } else {
         $this->data = strval($data['entity']);
     }
 }