public function preBuild(Fixture $fixture)
 {
     $parameters = $fixture->getParameters();
     if (isset($parameters['page']) && $parameters['page'] instanceof Fixture) {
         $additionalEntities = $parameters['page']->getAdditionalEntities();
         $properties = $fixture->getProperties();
         if (isset($properties['menu']) && $properties['menu']->getLocale() && isset($additionalEntities['translationNode_' . $properties['menu']->getLocale()])) {
             $fixture->getEntity()->setType(BaseMenuItem::TYPE_PAGE_LINK);
             $fixture->getEntity()->setNodeTranslation($additionalEntities['translationNode_' . $properties['menu']->getLocale()]);
         }
     }
     return;
 }
 public function parseFixture(Fixture $fixture, $providers, $fixtures = [])
 {
     $entities = [];
     foreach ($fixtures as $key => $ref) {
         $entities[$key] = $ref->getEntity();
     }
     $fixture->setProperties($this->parseArray($fixture->getProperties(), $providers, $entities, [$fixture, 'fixtures' => $fixtures]));
     $fixture->setParameters($this->parseArray($fixture->getParameters(), $providers, $fixtures, [$fixture, 'fixtures' => $fixtures]));
     $fixture->setTranslations($this->parseArray($fixture->getTranslations(), $providers, $fixtures, [$fixture, 'fixtures' => $fixtures]));
 }
 public function postBuild(Fixture $fixture)
 {
     /** @var Media $media */
     $media = $fixture->getEntity();
     $filePath = $media->getOriginalFilename();
     $data = new File($filePath, true);
     $contentType = $this->mimeTypeGuesser->guess($data->getPathname());
     if (method_exists($data, 'getClientOriginalName')) {
         $media->setOriginalFilename($data->getClientOriginalName());
     } else {
         $media->setOriginalFilename($data->getFilename());
     }
     if ($media->getName() === null) {
         $media->setName($media->getOriginalFilename());
     }
     $media->setContent($data);
     $media->setContentType($contentType);
     $media->setFolder($this->folder);
     $this->fileHandler->prepareMedia($media);
     $this->fileHandler->updateMedia($media);
     $this->fileHandler->saveMedia($media);
 }
 public function postFlushBuild(Fixture $fixture)
 {
     $params = $fixture->getParameters();
     $translations = $fixture->getTranslations();
     $original = $fixture->getEntity();
     if (!isset($params['page']) || empty($translations)) {
         throw new \Exception('No page reference and/or translations detected for pagepart fixture ' . $fixture->getName() . ' (' . $fixture->getClass() . ')');
     }
     $pageFixture = $params['page'];
     if (!$pageFixture instanceof Fixture) {
         throw new \Exception('Could not find a reference "' . $params['page'] . '"" for fixture ' . $fixture->getName() . ' (' . $fixture->getClass() . ')');
     }
     $additionalEntities = $pageFixture->getAdditionalEntities();
     $pp = $original;
     $first = null;
     foreach ($translations as $language => $data) {
         $key = $pageFixture->getName() . '_' . $language;
         if (!isset($additionalEntities[$key])) {
             continue;
         }
         if ($first !== null) {
             $pp = clone $original;
         }
         $page = $additionalEntities[$key];
         $this->populator->populate($pp, $data);
         $this->em->persist($pp);
         $this->em->flush($pp);
         // Find latest position.
         $position = array_key_exists('position', $params) ? $params['position'] : null;
         $context = isset($params['context']) ? $params['context'] : 'main';
         if (is_null($position)) {
             $pageParts = $this->pagePartRepo->getPagePartRefs($page, $context);
             $position = count($pageParts) + 1;
         }
         $this->pagePartRepo->addPagePart($page, $pp, $position, $context);
         $first = false;
     }
 }
 public function postFlushBuild(Fixture $fixture)
 {
     $entities = $fixture->getAdditionalEntities();
     $fixtureParams = $fixture->getParameters();
     foreach ($fixture->getTranslations() as $language => $data) {
         /** @var HasNodeInterface $page */
         $page = $entities[$fixture->getName() . '_' . $language];
         /** @var NodeTranslation $translationNode */
         $translationNode = $entities['translationNode_' . $language];
         $pagecreator = array_key_exists('creator', $fixtureParams) ? $fixtureParams['creator'] : 'pagecreator';
         $creator = $this->userRepo->findOneBy(array('username' => $pagecreator));
         $nodeVersion = new NodeVersion();
         $nodeVersion->setNodeTranslation($translationNode);
         $nodeVersion->setType('public');
         $nodeVersion->setOwner($creator);
         $nodeVersion->setRef($page);
         $translationNode->setPublicNodeVersion($nodeVersion);
         if (isset($fixtureParams['template'])) {
             $pageTemplateConfiguration = new PageTemplateConfiguration();
             $pageTemplateConfiguration->setPageId($page->getId());
             $pageTemplateConfiguration->setPageEntityName(ClassLookup::getClass($page));
             $pageTemplateConfiguration->setPageTemplate($fixtureParams['template']);
             $this->manager->persist($pageTemplateConfiguration);
         }
         $this->manager->persist($nodeVersion);
         $this->manager->persist($translationNode);
     }
     $this->manager->flush();
 }
 public function current(Fixture $fixture)
 {
     return $fixture->getSpec();
 }