Example #1
0
 protected static function browseTree($node)
 {
     $childObj = [];
     $sourceObj = [];
     foreach ($node->getChildren() as $child) {
         $childObj[] = static::browseTree($child);
     }
     $node->getChildren()->clear();
     foreach ($node->getNodeSources() as $nodeSource) {
         $trans = Kernel::getInstance()->getService('em')->getRepository("RZ\\Roadiz\\Core\\Entities\\Translation")->findOneByLocale($nodeSource->getTranslation()->getLocale());
         if (empty($trans)) {
             $trans = new Translation();
             $trans->setLocale($nodeSource->getTranslation()->getLocale());
             $trans->setName(Translation::$availableLocales[$nodeSource->getTranslation()->getLocale()]);
             Kernel::getInstance()->getService('em')->persist($trans);
         }
         $nodeSource->setTranslation($trans);
         foreach ($nodeSource->getUrlAliases() as $alias) {
             Kernel::getInstance()->getService('em')->persist($alias);
         }
         $nodeSource->setNode(null);
         Kernel::getInstance()->getService('em')->persist($nodeSource);
         $sourceObj[] = $nodeSource;
     }
     Kernel::getInstance()->getService('em')->persist($node);
     foreach ($childObj as $child) {
         $child->setParent($node);
     }
     foreach ($sourceObj as $nodeSource) {
         $nodeSource->setNode($node);
     }
     Kernel::getInstance()->getService('em')->flush();
     return $node;
 }
Example #2
0
 protected static function browseTree($tag, EntityManager $em)
 {
     $childObj = [];
     $sourceObj = [];
     foreach ($tag->getChildren() as $child) {
         $childObj[] = static::browseTree($child);
     }
     $tag->getChildren()->clear();
     foreach ($tag->getTranslatedTags() as $tagTranslation) {
         $trans = $em->getRepository("RZ\\Roadiz\\Core\\Entities\\Translation")->findOneByLocale($tagTranslation->getTranslation()->getLocale());
         if (empty($trans)) {
             $trans = new Translation();
             $trans->setLocale($tagTranslation->getTranslation()->getLocale());
             $trans->setName(Translation::$availableLocales[$tagTranslation->getTranslation()->getLocale()]);
             $em->persist($trans);
         }
         $tagTranslation->setTranslation($trans);
         $tagTranslation->setTag(null);
         $em->persist($tagTranslation);
         $sourceObj[] = $tagTranslation;
     }
     $em->persist($tag);
     foreach ($childObj as $child) {
         $child->setParent($tag);
     }
     foreach ($sourceObj as $tagTranslation) {
         $tagTranslation->setTag($tag);
     }
     $em->flush();
     return $tag;
 }
Example #3
0
 /**
  * Install theme.
  *
  * @param Symfony\Component\HttpFoundation\Request  $request
  * @param string                                    $classname
  * @param Doctrine\ORM\EntityManager                $em
  *
  * @return bool
  */
 public static function install(Request $request, $classname, EntityManager $em)
 {
     $data = static::getThemeInformation($classname);
     $fix = new Fixtures($em, $request);
     $data["className"] = $classname;
     $fix->installTheme($data);
     $installedLanguage = $em->getRepository("RZ\\Roadiz\\Core\\Entities\\Translation")->findAll();
     foreach ($installedLanguage as $key => $locale) {
         $installedLanguage[$key] = $locale->getLocale();
     }
     $exist = false;
     foreach ($data["supportedLocale"] as $locale) {
         if (in_array($locale, $installedLanguage)) {
             $exist = true;
         }
     }
     if ($exist === false) {
         $newTranslation = new Translation();
         $newTranslation->setLocale($data["supportedLocale"][0]);
         $newTranslation->setName(Translation::$availableLocales[$data["supportedLocale"][0]]);
         $em->persist($newTranslation);
         $em->flush();
     }
     $importFile = false;
     foreach ($data["importFiles"] as $name => $filenames) {
         foreach ($filenames as $filename) {
             $importFile = true;
             break;
         }
     }
     return $importFile;
 }
 public function getMenuAssignation(Translation $translation = null, $absolute = false)
 {
     if (null !== $translation) {
         return $translation->getViewer()->getTranslationMenuAssignation($this->request, $absolute);
     } else {
         return [];
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->questionHelper = $this->getHelperSet()->get('questionHelper');
     $this->entityManager = $this->getHelperSet()->get('em')->getEntityManager();
     $text = "";
     $name = $input->getArgument('name');
     $locale = $input->getArgument('locale');
     if ($name) {
         $translation = $this->entityManager->getRepository('RZ\\Roadiz\\Core\\Entities\\Translation')->findOneBy(['name' => $name]);
         if ($translation !== null) {
             $text = $translation->getOneLineSummary();
             $confirmation = new ConfirmationQuestion('<question>Are you sure to delete ' . $translation->getName() . ' translation?</question>', false);
             if ($input->getOption('delete')) {
                 if ($this->questionHelper->ask($input, $output, $confirmation)) {
                     $this->entityManager->remove($translation);
                     $this->entityManager->flush();
                     $text = '<info>Translation deleted…</info>' . PHP_EOL;
                 }
             } elseif ($input->getOption('enable')) {
                 $translation->setAvailable(true);
                 $this->entityManager->flush();
                 $text .= '<info>' . $translation->getName() . " enabled…</info>" . PHP_EOL;
             } elseif ($input->getOption('disable')) {
                 $translation->setAvailable(false);
                 $this->entityManager->flush();
                 $text .= '<info>' . $translation->getName() . " disabled…</info>" . PHP_EOL;
             }
         } else {
             if ($input->getOption('create')) {
                 if (!empty($locale)) {
                     $newTrans = new Translation();
                     $newTrans->setName($name)->setLocale($locale);
                     $this->entityManager->persist($newTrans);
                     $this->entityManager->flush();
                     $text = 'New translation : ' . $newTrans->getName() . PHP_EOL . 'Locale : ' . $newTrans->getLocale() . PHP_EOL . 'Available: ' . (string) $newTrans->isAvailable() . PHP_EOL;
                 } else {
                     $text = '<error>You must define a locale…</error>' . PHP_EOL;
                 }
             }
         }
     } else {
         $text = '<info>Existing translations…</info>' . PHP_EOL;
         $translations = $this->entityManager->getRepository('RZ\\Roadiz\\Core\\Entities\\Translation')->findAll();
         if (count($translations) > 0) {
             foreach ($translations as $trans) {
                 $text .= $trans->getOneLineSummary();
             }
         } else {
             $text = '<info>No available translations…</info>' . PHP_EOL;
         }
     }
     $output->writeln($text);
 }
 protected function makeTagRec($data)
 {
     $tag = new Tag();
     $tag->setTagName($data['tag_name']);
     $tag->setVisible($data['visible']);
     $tag->setLocked($data['locked']);
     foreach ($data["tag_translation"] as $source) {
         $trans = new Translation();
         $trans->setLocale($source['translation']);
         $trans->setName(Translation::$availableLocales[$source['translation']]);
         $tagSource = new TagTranslation($tag, $trans);
         $tagSource->setName($source["title"]);
         $tagSource->setDescription($source["description"]);
         $tag->getTranslatedTags()->add($tagSource);
     }
     foreach ($data['children'] as $child) {
         $tmp = $this->makeTagRec($child);
         $tag->addChild($tmp);
     }
     return $tag;
 }
Example #7
0
 /**
  * @param RZ\Roadiz\Core\Entities\Translation $translation
  * @param RZ\Roadiz\Core\Entities\Tag         $parent
  *
  * @return array Doctrine result array
  */
 public function findByParentWithTranslation(Translation $translation, Tag $parent = null)
 {
     $query = null;
     if ($parent === null) {
         $query = $this->_em->createQuery('
         SELECT t, tt FROM RZ\\Roadiz\\Core\\Entities\\Tag t
         INNER JOIN t.translatedTags tt
         INNER JOIN tt.translation tr
         WHERE t.parent IS NULL AND tr.id = :translation_id
         ORDER BY t.position ASC')->setParameter('translation_id', (int) $translation->getId());
     } else {
         $query = $this->_em->createQuery('
             SELECT t, tt FROM RZ\\Roadiz\\Core\\Entities\\Tag t
             INNER JOIN t.translatedTags tt
             INNER JOIN tt.translation tr
             INNER JOIN t.parent pt
             WHERE pt.id = :parent AND tr.id = :translation_id
             ORDER BY t.position ASC')->setParameter('parent', $parent->getId())->setParameter('translation_id', (int) $translation->getId());
     }
     try {
         return $query->getResult();
     } catch (\Doctrine\ORM\NoResultException $e) {
         return null;
     }
 }
 /**
  * @param RZ\Roadiz\Core\Entities\Translation $translation
  *
  * @return \Symfony\Component\Form\Form
  */
 private function buildMakeDefaultForm(Translation $translation)
 {
     $builder = $this->createFormBuilder()->add('translationId', 'hidden', ['data' => $translation->getId(), 'constraints' => [new NotBlank()]]);
     return $builder->getForm();
 }
Example #9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $this->entityManager = $this->getHelperSet()->get('em')->getEntityManager();
     $text = "";
     $question = new ConfirmationQuestion('Before installing Roadiz, did you create database schema? ' . PHP_EOL . 'If not execute: <info>bin/roadiz orm:schema-tool:create</info>' . PHP_EOL . '<question>Are you sure to perform installation?</question> : ', false);
     if ($input->getOption('no-interaction') || $helper->ask($input, $output, $question)) {
         /*
          * Create backend theme
          */
         if (!$this->hasDefaultBackend()) {
             $theme = new Theme();
             $theme->setAvailable(true)->setBackendTheme(true)->setClassName("Themes\\Rozier\\RozierApp");
             $this->entityManager->persist($theme);
             $this->entityManager->flush();
             $text .= '<info>Rozier back-end theme installed…</info>' . PHP_EOL;
         } else {
             $text .= '<error>A back-end theme is already installed.</error>' . PHP_EOL;
         }
         /**
          * Import default data
          */
         $installRoot = ROADIZ_ROOT . "/themes/Install";
         $yaml = new YamlConfiguration($installRoot . "/config.yml");
         $yaml->load();
         $data = $yaml->getConfiguration();
         if (isset($data["importFiles"]['roles'])) {
             foreach ($data["importFiles"]['roles'] as $filename) {
                 \RZ\Roadiz\CMS\Importers\RolesImporter::importJsonFile(file_get_contents($installRoot . "/" . $filename), $this->entityManager);
                 $text .= '     — <info>Theme file “' . $installRoot . "/" . $filename . '” has been imported.</info>' . PHP_EOL;
             }
         }
         if (isset($data["importFiles"]['groups'])) {
             foreach ($data["importFiles"]['groups'] as $filename) {
                 \RZ\Roadiz\CMS\Importers\GroupsImporter::importJsonFile(file_get_contents($installRoot . "/" . $filename), $this->entityManager);
                 $text .= '     — <info>Theme file “' . $installRoot . "/" . $filename . '” has been imported..</info>' . PHP_EOL;
             }
         }
         if (isset($data["importFiles"]['settings'])) {
             foreach ($data["importFiles"]['settings'] as $filename) {
                 \RZ\Roadiz\CMS\Importers\SettingsImporter::importJsonFile(file_get_contents($installRoot . "/" . $filename), $this->entityManager);
                 $text .= '     — <info>Theme files “' . $installRoot . "/" . $filename . '” has been imported.</info>' . PHP_EOL;
             }
         }
         /*
          * Create default translation
          */
         if (!$this->hasDefaultTranslation()) {
             $defaultTrans = new Translation();
             $defaultTrans->setDefaultTranslation(true)->setLocale("en")->setName("Default translation");
             $this->entityManager->persist($defaultTrans);
             $this->entityManager->flush();
             $text .= '<info>Default translation installed…</info>' . PHP_EOL;
         } else {
             $text .= '<error>A default translation is already installed.</error>' . PHP_EOL;
         }
         /*
          * Disable install mode
          */
         $configuration = new YamlConfiguration();
         if (false === $configuration->load()) {
             $configuration->setConfiguration($configuration->getDefaultConfiguration());
         }
         $configuration->setInstall(false);
         $configuration->writeConfiguration();
         // Clear result cache
         $cacheDriver = $this->entityManager->getConfiguration()->getResultCacheImpl();
         if ($cacheDriver !== null) {
             $cacheDriver->deleteAll();
         }
         $text .= 'Install mode has been changed to false.' . PHP_EOL;
     }
     $output->writeln($text);
 }
Example #10
0
 /**
  * @return void
  */
 protected function installDefaultTranslation()
 {
     $existing = $this->entityManager->getRepository('RZ\\Roadiz\\Core\\Entities\\Translation')->findOneBy(['defaultTranslation' => true, 'available' => true]);
     if (null === $existing) {
         $translation = new Translation();
         /*
          * Create a translation according to
          * current language
          */
         if (null !== $this->request) {
             $translation->setLocale($this->request->getLocale());
         } else {
             $translation->setLocale('en');
         }
         $translation->setDefaultTranslation(true);
         $translation->setName(Translation::$availableLocales[$translation->getLocale()]);
         $translation->setAvailable(true);
         $this->entityManager->persist($translation);
     }
 }
 public static function getUrlProvider()
 {
     $sources = array();
     /*
      * Test 1 - regular node
      */
     $n1 = new Node();
     $n1->setNodeName('page');
     $t1 = new Translation();
     $t1->setLocale('fr');
     $t1->setDefaultTranslation(true);
     $t1->setAvailable(true);
     $ns1 = new NodesSources($n1, $t1);
     $sources[] = array($ns1, '/page');
     /*
      * Test 2  - regular node
      */
     $n2 = new Node();
     $n2->setNodeName('page');
     $t2 = new Translation();
     $t2->setLocale('en');
     $t2->setDefaultTranslation(false);
     $t2->setAvailable(true);
     $ns2 = new NodesSources($n2, $t2);
     $sources[] = array($ns2, '/en/page');
     /*
      * Test 3 - home node
      */
     $n3 = new Node();
     $n3->setNodeName('page');
     $n3->setHome(true);
     $t3 = new Translation();
     $t3->setLocale('fr');
     $t3->setDefaultTranslation(true);
     $t3->setAvailable(true);
     $ns3 = new NodesSources($n3, $t3);
     $sources[] = array($ns3, '/');
     /*
      * Test 4 - home node non-default
      */
     $n4 = new Node();
     $n4->setNodeName('page');
     $n4->setHome(true);
     $t4 = new Translation();
     $t4->setLocale('en');
     $t4->setDefaultTranslation(false);
     $t4->setAvailable(true);
     $ns4 = new NodesSources($n4, $t4);
     $sources[] = array($ns4, '/en');
     /*
      * Test 5  - regular node with alias
      */
     $n5 = new Node();
     $n5->setNodeName('page');
     $t5 = new Translation();
     $t5->setLocale('en');
     $t5->setDefaultTranslation(false);
     $t5->setAvailable(true);
     $ns5 = new NodesSources($n5, $t5);
     $a5 = new Urlalias($ns5);
     $a5->setAlias('tralala-en');
     $ns5->getUrlAliases()->add($a5);
     $sources[] = array($ns5, '/tralala-en');
     /*
      * Test 6  - regular node with 1 parent
      */
     $n6 = new Node();
     $n6->setNodeName('other-page');
     $t6 = new Translation();
     $t6->setLocale('en');
     $t6->setDefaultTranslation(true);
     $t6->setAvailable(true);
     $ns6 = new NodesSources($n6, $t6);
     $ns6->getHandler()->setParentNodeSource($ns1);
     $sources[] = array($ns6, '/page/other-page');
     /*
      * Test 7  - regular node with 2 parents
      */
     $n7 = new Node();
     $n7->setNodeName('sub-page');
     $t7 = new Translation();
     $t7->setLocale('en');
     $t7->setDefaultTranslation(true);
     $t7->setAvailable(true);
     $ns7 = new NodesSources($n7, $t7);
     $ns7->getHandler()->setParentNodeSource($ns6);
     $sources[] = array($ns7, '/page/other-page/sub-page');
     /*
      * Test 8  - regular node with 1 parent and 2 alias
      */
     $n8 = new Node();
     $n8->setNodeName('other-page-alias');
     $t8 = new Translation();
     $t8->setLocale('en');
     $t8->setDefaultTranslation(true);
     $t8->setAvailable(true);
     $ns8 = new NodesSources($n8, $t8);
     $a8 = new Urlalias($ns8);
     $a8->setAlias('other-tralala-en');
     $ns8->getUrlAliases()->add($a8);
     $ns8->getHandler()->setParentNodeSource($ns5);
     $sources[] = array($ns8, '/tralala-en/other-tralala-en');
     /*
      * Test 9 - hidden node
      */
     $n9 = new Node();
     $n9->setNodeName('pagehidden');
     $n9->setVisible(false);
     $t9 = new Translation();
     $t9->setLocale('fr');
     $t9->setDefaultTranslation(true);
     $t9->setAvailable(true);
     $ns9 = new NodesSources($n9, $t9);
     $sources[] = array($ns9, '/pagehidden');
     /*
      * Test 10 - regular node with hidden parent
      */
     $n10 = new Node();
     $n10->setNodeName('page-with-hidden-parent');
     $t10 = new Translation();
     $t10->setLocale('fr');
     $t10->setDefaultTranslation(true);
     $t10->setAvailable(true);
     $ns10 = new NodesSources($n10, $t10);
     $ns10->getHandler()->setParentNodeSource($ns9);
     $sources[] = array($ns10, '/page-with-hidden-parent');
     return $sources;
 }
Example #12
0
 /**
  * @param RZ\Roadiz\Core\Entities\Translation $translation
  * @param RZ\Roadiz\Core\Entities\Node        $parent
  * @param AuthorizationChecker|null               $authorizationChecker When not null, only PUBLISHED node
  * will be request or with a lower status
  *
  * @return Doctrine\Common\Collections\ArrayCollection
  */
 public function findByParentWithTranslation(Translation $translation, Node $parent = null, AuthorizationChecker $authorizationChecker = null)
 {
     $txtQuery = 'SELECT n, ns FROM RZ\\Roadiz\\Core\\Entities\\Node n
                  INNER JOIN n.nodeSources ns
                  INNER JOIN ns.translation t';
     if ($parent === null) {
         $txtQuery .= PHP_EOL . 'WHERE n.parent IS NULL';
     } else {
         $txtQuery .= PHP_EOL . 'WHERE n.parent = :parent';
     }
     $txtQuery .= ' AND t.id = :translation_id';
     $this->alterQueryWithAuthorizationChecker($txtQuery, $authorizationChecker);
     $txtQuery .= ' ORDER BY n.position ASC';
     if ($parent === null) {
         $query = $this->_em->createQuery($txtQuery)->setParameter('translation_id', (int) $translation->getId());
     } else {
         $query = $this->_em->createQuery($txtQuery)->setParameter('parent', $parent)->setParameter('translation_id', (int) $translation->getId());
     }
     if (null !== $authorizationChecker) {
         $query->setParameter('status', Node::PUBLISHED);
     }
     try {
         return $query->getResult();
     } catch (\Doctrine\ORM\NoResultException $e) {
         return null;
     }
 }
 /**
  * @return array
  */
 public static function findBySearchQueryAndTranslationProvider()
 {
     $english = new Translation();
     $english->setLocale('en_GB');
     return array(array('Propos', 'GeneratedNodeSources\\NSPage', $english), array('Lorem markdownum', 'GeneratedNodeSources\\NSPage', $english));
 }
Example #14
0
 /**
  * Parse URL searching nodeName.
  *
  * Cannot use securityAuthorizationChecker here as firewall
  * has not been hit yet.
  *
  * @param array       &$tokens
  * @param Translation $translation
  *
  * @return RZ\Roadiz\Core\Entities\Node
  */
 protected function parseNode(array &$tokens, Translation $translation)
 {
     if (!empty($tokens[0])) {
         /*
          * If the only url token is for language, return Home page
          */
         if (in_array($tokens[0], Translation::getAvailableLocales()) && count($tokens) == 1) {
             if ($this->theme->getHomeNode() !== null) {
                 $node = $this->theme->getHomeNode();
                 if ($translation !== null) {
                     return $this->repository->findWithTranslation($node->getId(), $translation);
                 } else {
                     return $this->repository->findWithDefaultTranslation($node->getId());
                 }
             }
             return $this->repository->findHomeWithTranslation($translation);
         } else {
             $identifier = strip_tags($tokens[(int) (count($tokens) - 1)]);
             if ($identifier !== null && $identifier != '') {
                 return $this->repository->findByNodeNameWithTranslation($identifier, $translation);
             }
         }
     }
     return null;
 }
Example #15
0
 /**
  * Install theme screen.
  *
  * @param Symfony\Component\HttpFoundation\Request $request
  *
  * @return Symfony\Component\HttpFoundation\Response
  */
 public function themeInstallAction(Request $request)
 {
     $array = explode('\\', $request->get("classname"));
     $file = ROADIZ_ROOT . "/themes/" . $array[2] . "/config.yml";
     $yaml = new YamlConfiguration($file);
     $yaml->load();
     $data = $yaml->getConfiguration();
     $fix = new Fixtures($this->getService("em"), $request);
     $data["className"] = $request->get("classname");
     $fix->installTheme($data);
     $theme = $this->getService("em")->getRepository("RZ\\Roadiz\\Core\\Entities\\Theme")->findOneByClassName($request->get("classname"));
     $installedLanguage = $this->getService("em")->getRepository("RZ\\Roadiz\\Core\\Entities\\Translation")->findAll();
     foreach ($installedLanguage as $key => $locale) {
         $installedLanguage[$key] = $locale->getLocale();
     }
     $exist = false;
     foreach ($data["supportedLocale"] as $locale) {
         if (in_array($locale, $installedLanguage)) {
             $exist = true;
         }
     }
     if ($exist === false) {
         $newTranslation = new Translation();
         $newTranslation->setLocale($data["supportedLocale"][0]);
         $newTranslation->setName(Translation::$availableLocales[$data["supportedLocale"][0]]);
         $this->getService('em')->persist($newTranslation);
         $this->getService('em')->flush();
     }
     $importFile = false;
     foreach ($data["importFiles"] as $name => $filenames) {
         foreach ($filenames as $filename) {
             $importFile = true;
             break;
         }
     }
     if ($importFile === false) {
         return $this->redirect($this->generateUrl('installUserPage', ["id" => $theme->getId()]));
     } else {
         return $this->redirect($this->generateUrl('installImportThemePage', ["id" => $theme->getId()]));
     }
 }
Example #16
0
 /**
  * Parse URL searching nodeName.
  *
  * Cannot use securityAuthorizationChecker here as firewall
  * has not been hit yet.
  *
  * @param array       &$tokens
  * @param Translation $translation
  *
  * @return RZ\Roadiz\Core\Entities\Node
  */
 protected function parseNode(array &$tokens, Translation $translation)
 {
     if (!empty($tokens[0])) {
         /*
          * If the only url token is not for language
          */
         if (count($tokens) > 1 || !in_array($tokens[0], Translation::getAvailableLocales())) {
             $identifier = strip_tags($tokens[(int) (count($tokens) - 1)]);
             if ($identifier !== null && $identifier != '') {
                 return $this->repository->findByNodeNameWithTranslation($identifier, $translation);
             }
         }
     }
     return null;
 }
 public function getMenuAssignation(Translation $translation, $absolute = false)
 {
     return $translation->getViewer()->getTranslationMenuAssignation($this->request, $absolute);
 }
 /**
  * Search nodes sources by using Solr search engine
  * and a specific translation.
  *
  * @param string      $query       Solr query string (for example: `text:Lorem Ipsum`)
  * @param Translation $translation Current translation
  *
  * @return ArrayCollection | null
  */
 public function findBySearchQueryAndTranslation($query, Translation $translation)
 {
     // Update Solr Serach engine if setup
     if (true === Kernel::getService('solr.ready')) {
         $service = Kernel::getService('solr');
         $queryObj = $service->createSelect();
         $queryObj->setQuery('collection_txt:' . $query);
         // create a filterquery
         $queryObj->createFilterQuery('translation')->setQuery('locale_s:' . $translation->getLocale());
         $queryObj->addSort('score', $queryObj::SORT_DESC);
         // this executes the query and returns the result
         $resultset = $service->select($queryObj);
         if (0 === $resultset->getNumFound()) {
             return null;
         } else {
             $sources = new ArrayCollection();
             foreach ($resultset as $document) {
                 $sources->add($this->_em->find('RZ\\Roadiz\\Core\\Entities\\NodesSources', $document['node_source_id_i']));
             }
             return $sources;
         }
     }
     return null;
 }
 protected function makeNodeRec($data)
 {
     $nodetype = $this->em->getRepository('RZ\\Roadiz\\Core\\Entities\\NodeType')->findOneByName($data["node_type"]);
     $node = new Node($nodetype);
     $node->setNodeName($data['node_name']);
     $node->setHome($data['home']);
     $node->setVisible($data['visible']);
     $node->setStatus($data['status']);
     $node->setLocked($data['locked']);
     $node->setPriority($data['priority']);
     $node->setHidingChildren($data['hiding_children']);
     $node->setArchived($data['archived']);
     $node->setSterile($data['sterile']);
     $node->setChildrenOrder($data['children_order']);
     $node->setChildrenOrderDirection($data['children_order_direction']);
     foreach ($data["nodes_sources"] as $source) {
         $trans = new Translation();
         $trans->setLocale($source['translation']);
         $trans->setName(Translation::$availableLocales[$source['translation']]);
         $namespace = NodeType::getGeneratedEntitiesNamespace();
         $classname = $nodetype->getSourceEntityClassName();
         $class = $namespace . "\\" . $classname;
         $nodeSource = new $class($node, $trans);
         $nodeSource->setTitle($source["title"]);
         $nodeSource->setMetaTitle($source["meta_title"]);
         $nodeSource->setMetaKeywords($source["meta_keywords"]);
         $nodeSource->setMetaDescription($source["meta_description"]);
         $fields = $nodetype->getFields();
         foreach ($fields as $field) {
             if (!$field->isVirtual() && isset($source[$field->getName()])) {
                 if ($field->getType() == NodeTypeField::DATETIME_T || $field->getType() == NodeTypeField::DATE_T) {
                     $date = new \DateTime($source[$field->getName()]['date'], new \DateTimeZone($source[$field->getName()]['timezone']));
                     $setter = $field->getSetterName();
                     $nodeSource->{$setter}($date);
                 } else {
                     $setter = $field->getSetterName();
                     $nodeSource->{$setter}($source[$field->getName()]);
                 }
             }
         }
         if (!empty($source['url_aliases'])) {
             foreach ($source['url_aliases'] as $url) {
                 $alias = new UrlAlias($nodeSource);
                 $alias->setAlias($url['alias']);
                 $nodeSource->addUrlAlias($alias);
             }
         }
         $node->getNodeSources()->add($nodeSource);
     }
     if (!empty($data['tags'])) {
         foreach ($data["tags"] as $tag) {
             $tmp = $this->em->getRepository('RZ\\Roadiz\\Core\\Entities\\Tag')->findOneBy(["tagName" => $tag]);
             $node->getTags()->add($tmp);
         }
     }
     if (!empty($data['children'])) {
         foreach ($data['children'] as $child) {
             $tmp = $this->makeNodeRec($child);
             $node->addChild($tmp);
         }
     }
     return $node;
 }