protected function exportNode($position, Domain $domain, Node $node, ExportPointer $exportPointer) { $data = $node->toArray(TableMap::TYPE_CAMELNAME); if (!$node->getUrn()) { return; } $path = $node->getUrn(); $exportPointer->pushPath($path); if ($node->getId() === $domain->getStartnodeId()) { $domain->setVirtualColumn('startnodePath', $path); } $nodeData = $this->clearData($data, ['id', 'lft', 'rgt', 'lvl', 'pid', 'urn', 'domainId'], ['type' => 0, 'layout' => 'default', 'visible' => true]); $nodeData['sort'] = $position; $contents = $node->getContents(); $contentsData = []; foreach ($contents as $content) { $contentData = $content->toArray(TableMap::TYPE_CAMELNAME); $jsonDecoded = json_decode($contentData['content'], true); if (JSON_ERROR_NONE === json_last_error()) { $contentData['content'] = $jsonDecoded; } $contentData = $this->clearData($contentData, ['id', 'nodeId'], ['template' => 'JarvesBundle:Default:content.html.twig', 'type' => 'text']); $contentsData[] = $contentData; } $nodeData['contents'] = $contentsData; $exportPointer->addData($nodeData, '.yml'); foreach ($node->getChildren() as $idx => $child) { $this->exportNode($idx, $domain, $child, $exportPointer); } $exportPointer->popPath(); }
public function registerMainPage(Node $page) { $domain = $this->pageStack->getDomain($page->getDomainId()); $clazz = 'jarves.page_controller'; $domainUrl = $domain->getMaster() ? '' : '/' . $domain->getLang(); $url = $this->pageStack->getRouteUrl($page->getId()); $controller = $clazz . ':handleAction'; if ('' !== $url && '/' !== $url && $domain && $domain->getStartnodeId() == $page->getId()) { //This is the start page, so add a redirect controller $this->routes->add('jarves_frontend_page_redirect_to_startpage_' . $domain->getId(), new SyRoute($url, array('_controller' => $clazz . ':redirectToStartPageAction', 'jarvesFrontend' => true, 'nodeId' => $page->getId()))); $url = $domainUrl; } $this->routes->add('jarves_frontend_page_' . $page->getId() . '-' . preg_replace('/\\W/', '_', $page->getUrn()), new SyRoute($url, array('_controller' => $controller, 'jarvesFrontend' => true, 'nodeId' => $page->getId()))); }