Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $domains = DomainQuery::create()->find();
     $exportPointer = new ExportPointer();
     //        $basePath = 'jarves-export/' . date('Ymd-His'). '/';
     $basePath = 'app/jarves/';
     $fs = new Filesystem();
     $fs->remove($basePath);
     foreach ($domains as $domain) {
         $domainData = $domain->toArray(TableMap::TYPE_CAMELNAME);
         $exportPointer->pushPath('website/' . $domainData['domain']);
         $nodes = NodeQuery::create()->filterByDomain($domain)->orderByLft()->filterByLft(1, Criteria::GREATER_THAN)->filterByLvl(1)->find();
         foreach ($nodes as $idx => $node) {
             $this->exportNode($idx, $domain, $node, $exportPointer);
         }
         $domainData = $this->clearData($domainData, ['id', 'startnodeId']);
         if ($domain->hasVirtualColumn('startnodePath')) {
             $domainData['startnode'] = $domain->getVirtualColumn('startnodePath');
         } else {
             $output->writeln(sprintf('<error>Domain %s has no start node defined</error>', $domain->getDomain()));
         }
         $exportPointer->addData($domainData, '.yml');
         $exportPointer->popPath();
     }
     $files = FileQuery::create()->find();
     $fileReferences = [];
     foreach ($files as $file) {
         $fileReferences[$file->getId()] = $file->getPath();
     }
     $exportPointer->addData($fileReferences, 'file_references.yml');
     foreach ($exportPointer->data as $path => $data) {
         $path = $basePath . $path;
         if (!is_dir(dirname($path))) {
             mkdir(dirname($path), 0770, true);
         }
         $yml = $this->dumpYaml($data);
         $output->writeln(sprintf('write %s', $path));
         file_put_contents($path, $yml);
     }
     $output->writeln(sprintf('Done.'));
 }
Example #2
0
 /**
  * Injects all necessary files to get the Jarves Content Editor working
  * on the current page response.
  *
  * This register in `parent.jarves` a new jarves.Editor.
  */
 public function registerEditor()
 {
     $this->addMainResources(['noJs' => true]);
     $this->addSessionScripts();
     $page = $this->pageStack->getCurrentPage();
     $response = $this->pageStack->getPageResponse();
     $response->addJsFile('@JarvesBundle/admin/mootools-core-1.4.5-fixed-memory-leak.js');
     $response->addJsFile('@JarvesBundle/admin/mootools-more.js');
     $response->setResourceCompression(false);
     $response->setDomainHandling(false);
     $request = $this->pageStack->getRequest();
     $nodeArray['id'] = $page->getId();
     $nodeArray['title'] = $page->getTitle();
     $nodeArray['domainId'] = $page->getDomainId();
     $nodeArray['theme'] = $page->getTheme();
     $nodeArray['layout'] = $request->query->get('_jarves_editor_layout') ?: $page->getLayout();
     $domain = DomainQuery::create()->findPk($page->getDomainId());
     $domainArray['id'] = $domain->getId();
     $domainArray['domain'] = $domain->getDomain();
     $domainArray['path'] = $domain->getPath();
     $domainArray['theme'] = $domain->getTheme();
     $domainArray['themeOptions'] = $domain->getThemeOptions();
     $options = ['id' => $request->query->get('_jarves_editor_id'), 'node' => $nodeArray, 'domain' => $domainArray];
     if (is_array($extraOptions = $request->query->get('_jarves_editor_options'))) {
         $options = array_merge($options, $extraOptions);
         $options['standalone'] = filter_var($options['standalone'], FILTER_VALIDATE_BOOLEAN);
     }
     $response->addJsAtBottom('window.editor = new parent.jarves.Editor(' . json_encode($options) . ', document.documentElement);');
 }
Example #3
0
 public function installDemoData()
 {
     \Jarves\Model\DomainQuery::create()->deleteAll();
     \Jarves\Model\NodeQuery::create()->deleteAll();
     \Jarves\Model\ContentQuery::create()->deleteAll();
     \Jarves\Model\AppLockQuery::create()->deleteAll();
     \Jarves\Model\AclQuery::create()->deleteAll();
     $domainName = $this->getDomain();
     $domainName = explode(':', $domainName)[0];
     $domain = new Domain();
     $domain->setDomain($domainName);
     $path = $this->getPath();
     $domain->setPath($path);
     $domain->setTitleFormat('%title% | Node title - My Website - change me under domain settings.');
     $domain->setMaster(1);
     $domain->setLang('en');
     $domain->setResourceCompression(0);
     $domain->setTheme('jarvesDemoTheme');
     $domain->setSearchIndexKey(md5(time() . '-' . rand()));
     $domain->save();
     $root = new Node();
     $root->setDomainId($domain->getId());
     $root->makeRoot();
     $root->setTitle('root');
     $root->setUrn('');
     $root->save();
     //setup live workspace
     WorkspaceQuery::create()->deleteAll();
     $workspace = new Workspace();
     $workspace->setTitle('LIVE');
     $workspace->setCreated(time());
     $workspace->save();
     $id = $workspace->getId();
     if ($id != 1) {
         WorkspaceQuery::create()->filterById($id)->update(array('Id' => 1));
     }
     $defaultLayout = 'default';
     $defaultContentTemplate = 'JarvesBundle:Default:content.html.twig';
     $Nodes = array(array(0, 'Blog', $defaultLayout, 'home', '', array('1' => array(array('text', 'Jarves cms has been installed!', $defaultContentTemplate, '<p>Jarves cms has been installed correctly.</p><p>&nbsp;</p><p><a href="http://www.jarves.io">Jarves cms Website</a></p><p>&nbsp;</p><p>&nbsp;</p><p>Go to <a href="jarves">administration</a> to manage your new website.</p><p>&nbsp;</p><p><strong>Default login:</strong></p><p><strong><br /></strong></p><p style="padding-left: 10px;">Username: admin</p><p style="padding-left: 10px;">Password: admin</p>'), array('plugin', '', $defaultContentTemplate, '{"bundle":"JarvesPublicationBundle","plugin":"listing","options":{"itemsPerPage":10,"maxPages":10,"detailPage":"","template":"default.html.twig","categoryId":[],"enableRss":false}}')), '2' => array(array('plugin', '» CATEGORIES', $defaultContentTemplate, '{"bundle":"JarvesPublicationBundle","plugin":"categoryList","options":{"listNode":"1","template":"default.html.twig","category_rsn":[]}}'))), array(array(1, 'Article', $defaultLayout, 'article', '', array(), array(), 0))), array(0, 'Links', $defaultLayout, 'links', '', array('1' => array(array('text', 'Links', $defaultContentTemplate, 'Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi.')), '2' => array(array('text', '» About', $defaultContentTemplate, 'hoho'))), array(array(1, 'Jarves cms Official Website', $defaultLayout, 'www-jarves-org', 'http://www.jarves.io/'), array(1, 'Jarves cms Documentation', $defaultLayout, 'docu-jarves-org', 'http://docu.jarves.io/'), array(1, 'Jarves cms Extensions', $defaultLayout, 'www-jarves-org-extensions', 'http://www.jarves.io/extensions'))), array(0, 'About me', $defaultLayout, 'about-me', '', array('1' => array(array('text', 'About me', $defaultContentTemplate, 'Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi.')), '2' => array(array('text', 'Hi, my Name is', $defaultContentTemplate, 'John Doe and I\'m a creative dude living in Springfield. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt...'))), array(array(0, 'Sublink 1', $defaultLayout, 'sublink-1', '', array('1' => array(array('text', 'Sublink 1', $defaultContentTemplate, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.')))), array(0, 'Sublink 2', $defaultLayout, 'sublink-2', '', array('1' => array(array('text', 'Sublink 1', $defaultContentTemplate, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.<br/><br/><h3>Lorem ...</h3>ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.')))))), array(2, 'Footer Navigation', '', '', '', array(), array(array(0, 'Sitemap', $defaultLayout, 'sitemap', '', array('1' => array(array('plugin', 'Sitemap', $defaultContentTemplate, 'todo')))), array(0, 'Contact', $defaultLayout, 'contact', '', array('1' => array(array('plugin', 'Contact form', $defaultContentTemplate, 'todo')))), array(0, 'Impress', $defaultLayout, 'impress', '', array('1' => array(array('text', 'Impress', $defaultContentTemplate, 'Owner: <b>Name</b><br/>Street, Nr<br/>Country<br/>')))))), array(3, 'Footer text', '', '', '', array('1' => array(array('text', '', $defaultContentTemplate, '<p>&copy; my Node | <a href="http://www.jarves.io/">CMS</a> powered by Jarves cms - simply different</p>'))), array()));
     /*
      * 0: type
      * 1: Title
      * 2: layout
      * 3: url
      * 4: link target
      * 5: contents
      * 6: children
      * 7: visible
      */
     foreach ($Nodes as $Node) {
         $oNode = new Node();
         $oNode->setDomainId($domain->getId());
         $oNode->setType($Node[0]);
         $oNode->setTitle($Node[1]);
         $oNode->setLayout($Node[2]);
         $oNode->setUrn($Node[3]);
         $oNode->insertAsLastChildOf($root);
         if (isset($Node[7])) {
             $oNode->setVisible($Node[7]);
         } else {
             $oNode->setVisible(1);
         }
         $oNode->save();
         if ($Node[4]) {
             $oNode->setLink($Node[4]);
         }
         if ($Node[5]) {
             $this->installContents($oNode, $Node[5]);
         }
         if ($Node[6]) {
             $this->installNodes($oNode, $Node[6]);
         }
     }
     $startNode = NodeQuery::create()->filterByDomainId($domain->getId())->findOneByLft(2);
     $domain->setStartnodeId($startNode->getId());
     $domain->save();
     LanguageQuery::create()->deleteAll();
     $h = fopen(__DIR__ . '/Resources/package/ISO_639-1_codes.csv', 'r');
     if ($h) {
         while (($data = fgetcsv($h, 1000, ",")) !== false) {
             $lang = new Language();
             $lang->setCode($data[0]);
             $lang->setTitle($data[1]);
             $lang->setLangtitle($data[2]);
             $lang->save();
         }
     }
     LanguageQuery::create()->filterByCode('en')->update(array('Visible' => 1));
     //search footer id
     $footerNavi = NodeQuery::create()->findOneByTitle('Footer Navigation');
     $footerText = NodeQuery::create()->findOneByTitle('Footer text');
     $domainThemeProperties = ['footerNavigation' => $footerNavi->getId(), 'footerTray' => $footerText->getId()];
     $domain->setThemeOptions($domainThemeProperties);
     $domain->save();
     SessionQuery::create()->deleteAll();
     UserGroupQuery::create()->deleteAll();
     UserQuery::create()->deleteAll();
     GroupQuery::create()->deleteAll();
     AclQuery::create()->deleteAll();
     $groupGuest = new Group();
     $groupGuest->setName('Guest');
     $groupGuest->setDescription('All anonymous user');
     $groupGuest->save();
     $id = $groupGuest->getId();
     GroupQuery::create()->filterById($id)->update(array('Id' => 0));
     $groupAdmin = new Group();
     $groupAdmin->setName('Admin');
     $groupAdmin->setDescription('Super user');
     $groupAdmin->save();
     $id = $groupAdmin->getId();
     GroupQuery::create()->filterById($id)->update(array('Id' => 1));
     $groupAdmin->setId(1);
     $groupUsers = new Group();
     $groupUsers->setName('Users');
     $groupUsers->setDescription('Registered user');
     $groupUsers->save();
     $admin = new User();
     $admin->setUsername('admin');
     $admin->setFirstName('Admini');
     $admin->setLastName('strator');
     $admin->setEmail('admin@localhost');
     $admin->setActivate(1);
     $encoderFactory = $this->container->get('security.encoder_factory');
     $encoder = $encoderFactory->getEncoder($admin);
     $admin->setPassword($encoder->encodePassword('admin', null));
     $liveWorkspace = WorkspaceQuery::create()->findOneById(1);
     $admin->addWorkspace($liveWorkspace);
     $settings = new \Jarves\Properties(array('userBg' => '/admin/images/userBgs/defaultImages/color-blue.jpg', 'adminLanguage' => 'en'));
     $admin->setSettings($settings);
     $admin->save();
     $id = $admin->getId();
     UserQuery::create()->filterById($id)->update(array('Id' => 1));
     $admin->setId(1);
     $admin->addGroup($groupAdmin);
     $admin->save();
 }
Example #4
0
 public function testNestedSubPermission()
 {
     $this->getACL()->setCaching(false);
     $this->getACL()->removeObjectRules('jarves/node');
     $tokenStorage = $this->getTokenStorage();
     $token = new UsernamePasswordToken(UserQuery::create()->findOneByUsername('test'), null, "main");
     $tokenStorage->setToken($token);
     $user = $this->getPageStack()->getUser();
     $this->assertEquals('test', $user->getUsername());
     $domain = DomainQuery::create()->findOne();
     $root = NodeQuery::create()->findRoot($domain->getId());
     $subNode = new Node();
     $subNode->setTitle('TestNode tree');
     $subNode->insertAsFirstChildOf($root);
     $subNode->save();
     $subNode2 = new Node();
     $subNode2->setTitle('TestNode sub');
     $subNode2->insertAsFirstChildOf($subNode);
     $subNode2->save();
     //make access for all
     $rule = new Acl();
     $rule->setAccess(true);
     $rule->setObject('jarves/node');
     $rule->setTargetType(\Jarves\ACL::TARGET_TYPE_USER);
     $rule->setTargetId($user->getId());
     $rule->setMode(\Jarves\ACL::MODE_ALL);
     $rule->setConstraintType(\Jarves\ACL::CONSTRAINT_ALL);
     $rule->setPrio(2);
     $rule->save();
     //revoke access for all children of `TestNode tree`
     $rule2 = new Acl();
     $rule2->setAccess(false);
     $rule2->setObject('jarves/node');
     $rule2->setTargetType(\Jarves\ACL::TARGET_TYPE_USER);
     $rule2->setTargetId($user->getId());
     $rule2->setMode(\Jarves\ACL::MODE_ALL);
     $rule2->setConstraintType(\Jarves\ACL::CONSTRAINT_CONDITION);
     $rule2->setConstraintCode(json_encode(['title', '=', 'TestNode tree']));
     $rule2->setPrio(3);
     $rule2->setSub(true);
     $rule2->save();
     $this->getCacher()->invalidateCache('core');
     $node1RequestListing = ACLRequest::create('jarves/node', $subNode->getId())->onlyListingMode();
     $node2RequestListing = ACLRequest::create('jarves/node', $subNode2->getId())->onlyListingMode();
     $this->assertFalse($this->getACL()->check($node1RequestListing));
     $this->assertFalse($this->getACL()->check($node2RequestListing));
     $items = $this->getObjects()->getBranch('jarves/node', $subNode->getId(), null, 1, null, ['permissionCheck' => true]);
     $this->assertNull($items, 'rule2 revokes the access to all elements');
     $item = $this->getObjects()->get('jarves/node', $subNode2->getId(), ['permissionCheck' => true]);
     $this->assertNull($item);
     // Deactivate sub
     $rule2->setSub(false);
     $rule2->save();
     $this->assertFalse($this->getACL()->check($node1RequestListing));
     $this->assertTrue($this->getACL()->check($node2RequestListing));
     $items = $this->getObjects()->getBranch('jarves/node', $subNode->getId(), null, 1, null, ['permissionCheck' => true]);
     $this->assertEquals('TestNode sub', $items[0]['title'], 'We got TestNode sub');
     $item = $this->getObjects()->get('jarves/node', $subNode2->getId(), ['permissionCheck' => true]);
     $this->assertEquals('TestNode sub', $item['title'], 'We got TestNode sub');
     // Activate access
     $rule2->setAccess(true);
     $rule2->save();
     $this->assertTrue($this->getACL()->check($node1RequestListing));
     $this->assertTrue($this->getACL()->check($node2RequestListing));
     $items = $this->getObjects()->getBranch('jarves/node', $subNode->getId(), null, 1, null, ['permissionCheck' => true]);
     $this->assertEquals('TestNode sub', $items[0]['title'], 'We got TestNode sub');
     $subNode->delete();
     $subNode2->delete();
     $rule->delete();
     $rule2->delete();
     $this->getACL()->setCaching(true);
 }
Example #5
0
 /**
  * Returns the domain if found
  *
  * @return \Jarves\Model\Domain|null
  *
  * @throws \Propel\Runtime\Exception\PropelException
  */
 public function searchDomain()
 {
     $request = $this->getRequest();
     $dispatcher = $this->eventDispatcher;
     if ($domainId = $request->get('_jarves_editor_domain')) {
         $hostname = DomainQuery::create()->select('domain')->findOneById($domainId);
     } else {
         $hostname = $request->getHost();
     }
     $title = sprintf('Searching Domain [%s]', $hostname);
     $this->stopwatch->start($title);
     /** @var \Jarves\Model\Domain $foundDomain */
     $foundDomain = null;
     $possibleLanguage = $this->getPossibleLanguage();
     $hostnameWithLanguage = $hostname . '/' . $possibleLanguage;
     $cachedDomains = $this->cacher->getDistributedCache('core/domains');
     if ($cachedDomains) {
         $cachedDomains = @unserialize($cachedDomains);
     }
     if (!is_array($cachedDomains)) {
         $cachedDomains = array();
         $domains = DomainQuery::create()->find();
         foreach ($domains as $domain) {
             $key = $domain->getDomain();
             $langKey = '';
             if (!$domain->getMaster()) {
                 $langKey = '/' . $domain->getLang();
             }
             $cachedDomains[$key . $langKey] = $domain;
             if ($domain->getRedirect()) {
                 $redirects = $domain->getRedirect();
                 $redirects = explode(',', str_replace(' ', '', $redirects));
                 foreach ($redirects as $redirectDomain) {
                     $cachedDomains['!redirects'][$redirectDomain . $langKey] = $key . $langKey;
                 }
             }
             if ($domain->getAlias()) {
                 $aliases = $domain->getAlias();
                 $aliases = explode(',', str_replace(' ', '', $aliases));
                 foreach ($aliases as $aliasDomain) {
                     $cachedDomains['!aliases'][$aliasDomain . $langKey] = $key . $langKey;
                 }
             }
         }
         $this->cacher->setDistributedCache('core/domains', serialize($cachedDomains));
     }
     //search redirect
     if (isset($cachedDomains['!redirects']) && (isset($cachedDomains['!redirects'][$hostnameWithLanguage]) && ($redirectToDomain = $cachedDomains['!redirects'][$hostnameWithLanguage])) || isset($cachedDomains['!redirects'][$hostname]) && ($redirectToDomain = $cachedDomains['!redirects'][$hostname])) {
         $foundDomain = $cachedDomains[$redirectToDomain];
         $dispatcher->dispatch('core/domain-redirect', new GenericEvent($foundDomain));
         return null;
     }
     //search alias
     if (isset($cachedDomains['!aliases']) && (isset($cachedDomains['!aliases'][$hostnameWithLanguage]) && ($aliasHostname = $cachedDomains['!aliases'][$hostnameWithLanguage]) || isset($cachedDomains['!aliases'][$hostname]) && ($aliasHostname = $cachedDomains['!aliases'][$hostname]))) {
         $foundDomain = $cachedDomains[$aliasHostname];
         $hostname = $aliasHostname;
     } else {
         if (isset($cachedDomains[$hostname])) {
             $foundDomain = $cachedDomains[$hostname];
         }
     }
     if (!$foundDomain) {
         $dispatcher->dispatch('core/domain-not-found', new GenericEvent($hostname));
         $this->stopwatch->stop($title);
         return null;
     }
     $foundDomain->setRealDomain($hostname);
     $this->stopwatch->stop($title);
     return $foundDomain;
 }
Example #6
0
 /**
  * @group test
  */
 public function testPatchDomain()
 {
     $newDomain = new Domain();
     $newDomain->setPath('/');
     $newDomain->setDomain('testDomainName');
     $newDomain->setTheme('defaultTheme');
     $newDomain->save();
     $patched = $this->getObjects()->patch('jarves/domain', $newDomain->getId(), ['domain' => 'testdomain.tld', 'theme' => 'coreLayouts']);
     $this->assertTrue($patched);
     $domain = DomainQuery::create()->findOneById($newDomain->getId());
     $this->assertEquals('testdomain.tld', $domain->getDomain());
     $this->assertEquals('coreLayouts', $domain->getTheme());
     $newDomain->delete();
 }
Example #7
0
 protected function import(InputInterface $input, OutputInterface $output)
 {
     $basePath = 'app/jarves/';
     $openedFiles = [];
     $domains = [];
     $nodes = [];
     $rootNodes = [];
     $ymlParser = new Parser();
     Propel::getWriteConnection('default')->beginTransaction();
     //import files
     $fileReferencesPath = $basePath . '/file_references.yml';
     if (file_exists($fileReferencesPath)) {
         $openedFiles[$fileReferencesPath] = filemtime($fileReferencesPath);
         $fileReferences = $ymlParser->parse(file_get_contents($fileReferencesPath));
         $output->writeln(sprintf('Import %d file references ...', count($fileReferences)));
         FileQuery::create()->deleteAll();
         foreach ($fileReferences as $id => $path) {
             $file = new File();
             $file->setId($id);
             $file->setPath($path);
             $file->save();
         }
     }
     $relativePathBase = $basePath . 'website/';
     $dir = opendir($relativePathBase);
     while ($domainName = readdir($dir)) {
         if ('.' === $domainName || '..' === $domainName || '.yml' === substr($domainName, -4)) {
             continue;
         }
         $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($basePath . 'website/' . $domainName));
         $files = iterator_to_array($files);
         ksort($files);
         $output->writeln(sprintf('Import domain %s ...', $domainName));
         $domain = DomainQuery::create()->findOneByDomain($domainName);
         if (!$domain) {
             $domain = new Domain();
         }
         $ymlPath = $relativePathBase . $domainName . '.yml';
         $domainFromYml = $ymlParser->parse(file_get_contents($ymlPath));
         $openedFiles[$ymlPath] = filemtime($ymlPath);
         $oldData = $domain->toArray(TableMap::TYPE_CAMELNAME);
         $domain->fromArray(array_merge($oldData, $domainFromYml), TableMap::TYPE_CAMELNAME);
         $domain->setStartnodeId(null);
         if (isset($domainFromYml['startnode'])) {
             $domain->setVirtualColumn('startnodePath', $domainFromYml['startnode']);
         }
         $domain->save();
         $domains[$domainName] = $domain;
         NodeQuery::create()->filterByDomain($domain)->delete();
         $rootNode = new Node();
         $rootNode->setTitle('root');
         $rootNode->makeRoot();
         $rootNode->setDomain($domain);
         $rootNode->save();
         $rootNodes[$domainName] = $rootNode;
         $nodes[''] = $rootNode;
         $parentNodeQueue = [];
         /** @var \SplFileInfo $file */
         foreach ($files as $file) {
             if ('.' === $file->getFilename() || '..' === $file->getFilename() || '.yml' !== substr($file->getFilename(), -4)) {
                 continue;
             }
             $path = $file->getPath() . '/' . $file->getFilename();
             $path = substr($path, strlen($relativePathBase . $domainName) + 1);
             if (!$path) {
                 continue;
             }
             $parentPath = '';
             if (false !== strpos($path, '/')) {
                 $parentPath = dirname($path);
             }
             $baseName = substr(basename($path), 0, -4);
             //without .yml
             if ($baseName) {
                 //its a node
                 $node = isset($nodes[$path]) ? $nodes[$path] : new Node();
                 $ymlPath = $relativePathBase . $domainName . '/' . $path;
                 $nodeFromYml = $ymlParser->parse(file_get_contents($ymlPath));
                 $openedFiles[$ymlPath] = filemtime($ymlPath);
                 $node->fromArray($nodeFromYml, TableMap::TYPE_CAMELNAME);
                 $node->setDomain($domain);
                 $urn = $baseName;
                 if (false !== ($dotPos = strpos($baseName, '.'))) {
                     $prefix = substr($baseName, 0, $dotPos);
                     if ($prefix) {
                         $urn = substr($baseName, $dotPos + 1);
                     }
                 }
                 $node->setUrn($urn);
                 $output->writeln(sprintf('Import page %s%s ...', str_repeat('  ', substr_count($path, '/')), $node->getTitle()));
                 $nodes[substr($path, 0, -4)] = $node;
                 $end = isset($parentNodeQueue[$parentPath]) ? count($parentNodeQueue[$parentPath]) : 1;
                 $position = isset($nodeFromYml['sort']) ? $nodeFromYml['sort'] : $end;
                 $parentNodeQueue[$parentPath][$position][] = $node;
                 if (isset($nodeFromYml['contents'])) {
                     foreach ($nodeFromYml['contents'] as $idx => $contentFromYaml) {
                         if (isset($contentFromYaml['content']) && is_array($contentFromYaml['content'])) {
                             $contentFromYaml['content'] = json_encode($contentFromYaml['content']);
                         }
                         $content = new Content();
                         $content->setSort($idx);
                         $content->fromArray($contentFromYaml, TableMap::TYPE_CAMELNAME);
                         $content->setNode($node);
                     }
                     if ($domain->hasVirtualColumn('startnodePath') && substr($path, 0, -4) === $domain->getVirtualColumn('startnodePath')) {
                         $domain->setStartnode($node);
                     }
                 }
             }
         }
         //save queued nodes
         foreach ($parentNodeQueue as $parentPath => $nodesQueue) {
             ksort($nodesQueue);
             //key is sort
             /** @var Node $node */
             foreach ($nodesQueue as $position => $nodesToInsert) {
                 foreach ($nodesToInsert as $node) {
                     $node->insertAsLastChildOf($nodes[$parentPath]);
                     $node->save();
                     //saves Content as well.
                 }
             }
         }
         $domain->save();
     }
     Propel::getWriteConnection('default')->commit();
     $cacher = $this->getContainer()->get('jarves.cache.cacher');
     $cacher->invalidateCache('core');
     return $openedFiles;
 }