예제 #1
0
 /**
  * Sets up the PageTree object
  *
  * @param  ThemeInterface      $theme
  * @param  TemplateManager     $templateManager
  * @param  PageBlocksInterface $pageBlocks
  * @param  Template            $template
  * @return self
  */
 public function setUp(ThemeInterface $theme, TemplateManager $templateManager, PageBlocksInterface $pageBlocks, Template $template = null)
 {
     $this->templateManager = $templateManager;
     $this->pageBlocks = $pageBlocks;
     $this->theme = $theme;
     $this->dispatch(PageTreeEvent\PageTreeEvents::BEFORE_PAGE_TREE_SETUP, new PageTreeEvent\BeforePageTreeSetupEvent($this));
     $language = $this->getLanguage();
     $page = $this->getPage();
     if (null !== $language && null !== $page) {
         $this->pageBlocks->refresh($language->getId(), $page->getId());
     }
     $options = array();
     if (null !== $language) {
         $options["language"] = $language->getLanguageName();
     }
     $templateName = "";
     if (null !== $page) {
         $options["page"] = $page->getPageName();
         $templateName = $page->getTemplateName();
     }
     $this->template = null === $template ? $this->theme->getTemplate($templateName) : $template;
     if (null === $this->template) {
         return $this;
     }
     $this->assetsManager->withExtraAssets($this->cmsMode)->setUp($this->template, $options);
     $this->templateManager->refresh($this->theme->getThemeSlots(), $this->template, $this->pageBlocks);
     $this->setUpMetaTags($this->getSeo());
     $this->dispatch(PageTreeEvent\PageTreeEvents::AFTER_PAGE_TREE_SETUP, new PageTreeEvent\AfterPageTreeSetupEvent($this));
     return $this;
 }
 /**
  * @dataProvider templateAssetsManagerProvider
  */
 public function testSetUpTemplateAssetsManager($assetCollections, $listenersAssets, $containerAssets, $availableBlocks, $expectedResult, $options = array(), $extraAssets = true)
 {
     $this->assetsCollections = $assetCollections;
     $container = $this->initContainer($listenersAssets, $containerAssets);
     $template = $this->createTemplate($assetCollections);
     $blockManagerFactory = $this->initBlockManagerFactory($availableBlocks);
     $templateAssetsManager = new TemplateAssetsManager($container, $blockManagerFactory);
     $templateAssetsManager->withExtraAssets($extraAssets);
     $templateAssetsManager->setUp($template, $options);
     $this->assertEquals($expectedResult["externalStylesheets"], $templateAssetsManager->getExternalStylesheets());
     $this->assertEquals($expectedResult["externalJavascripts"], $templateAssetsManager->getExternalJavascripts());
     $this->assertEquals($expectedResult["internalStylesheets"], $templateAssetsManager->getInternalStylesheets());
     $this->assertEquals($expectedResult["internalJavascripts"], $templateAssetsManager->getInternalJavascripts());
 }