private function checkTemplatesSlots() { $template = $this->pageTree->getTemplate(); if (null === $template) { return; } $language = $this->pageTree->getLanguage(); $page = $this->pageTree->getPage(); $languageId = null !== $language ? $language->getId() : null; $pageId = null !== $page ? $page->getId() : null; $slotsAligner = $this->container->get('red_kite_cms.repeated_slots_aligner'); $slotsAligner->setLanguageId($languageId)->setPageId($pageId)->align($template, $this->theme->getThemeSlots()->getSlots()); }
private function initPageTree(Language $language, Page $page = null, Template $template = null) { $dataManager = new DataManager($this->factoryRepository); $dataManager->fromEntities($language, $page); $pageBlocks = clone $this->pageBlocks; if (null !== $page) { $pageBlocks->refresh($language->getId(), $page->getId()); } $assetsManager = clone $this->assetsManager; $assetsManager->setPageBlocks($pageBlocks); $pageTree = new PageTree($assetsManager, null, $dataManager); $pageTree->productionMode(true)->setUp($this->theme, clone $this->templateManager, $pageBlocks, $template); return $pageTree; }
/** * @dataProvider objectsProvider */ public function testGetObjectes($method) { $template = $this->createTemplate(); switch ($method) { case "getTheme": $object = $this->theme; break; case "getTemplateManager": $object = $this->templateManager; break; case "getPageBlocks": $object = $this->pageBlocks; break; case "getTemplate": $object = $template; break; } $this->completeSetup($template); $pageTree = new PageTree($this->templateAssetsManager, $this->dispatcher, $this->dataManager); $pageTree->setUp($this->theme, $this->templateManager, $this->pageBlocks, $template); $this->assertSame($object, $pageTree->__call($method, "")); }
public function save(PageTree $pageTree, Theme $theme, array $options) { return $pageTree->fakeSave(); }
protected function findTemplate(PageTree $pageTree) { $templateTwig = 'RedKiteCmsBundle:Cms:Welcome/welcome.html.twig'; if (null !== ($template = $pageTree->getTemplate())) { $themeName = $template->getThemeName(); $templateName = $template->getTemplateName(); $asset = new Asset($this->kernel, $themeName); $themeFolder = $asset->getRealPath(); if (false === $themeFolder || !is_file($themeFolder . '/Resources/views/Theme/' . $templateName . '.html.twig')) { $configuration = $this->container->get('red_kite_cms.configuration'); $cmsLanguage = $configuration->read('language'); $message = $this->container->get('translator')->trans('The template assigned to this page does not exist. This happens when you change a theme with a different number of templates from the active one. To fix this issue you shoud activate the previous theme again and change the pages which cannot be rendered by this theme', array(), 'RedKiteCmsBundle', $cmsLanguage); $this->container->get('session')->getFlashBag()->add('notice', $message); return $templateTwig; } if ($themeName != "" && $templateName != "") { $this->kernelPath = $this->container->getParameter('kernel.root_dir'); $templateTwig = is_file(sprintf('%s/Resources/views/%s/%s.html.twig', $this->kernelPath, $themeName, $templateName)) ? sprintf('::%s/%s.html.twig', $themeName, $templateName) : sprintf('%s:Theme:%s.html.twig', $themeName, $templateName); } } return $templateTwig; }
/** * Generates the template's subsections and the full template itself */ public function generateTemplate(PageTree $pageTree, ThemeInterface $theme, array $options) { $this->language = $pageTree->getLanguage(); $this->page = $pageTree->getPage(); switch ($options["type"]) { case 'Base': $this->template = $pageTree->getTemplate(); $this->generateBaseTemplate($pageTree, $theme, $options); $this->baseFolder = "/base"; $this->fileName = $this->template->getTemplateName(); break; case 'Pages': $this->generatePageTemplate($pageTree, $theme, $options); $this->baseFolder = ""; $this->fileName = $this->page->getPageName(); break; } return $this; }