/**
  * @dataProvider templateOptionsProvider
  */
 public function testGenerateTemplate($options, $expectedResult, $filename, $isPublished)
 {
     $times = 1;
     $theme = $this->getMock("RedKiteLabs\\ThemeEngineBundle\\Core\\Theme\\ThemeInterface");
     if ($options["type"] == "Base") {
         $times = 0;
         $theme->expects($this->once())->method('getThemeName')->will($this->returnValue("BootbusinessThemeBundle"));
     }
     $metatagManager = $this->createMetatagManager($times, $isPublished);
     $assetManager = $this->createAssetManager($times, $isPublished);
     $contentManager = $this->createContentManager($isPublished);
     $root = vfsStream::setup('root');
     $pageTree = $this->createPageTree((bool) (!$times), $isPublished);
     $twigTemplateWrite = new TwigTemplateWriter($metatagManager, $assetManager, $contentManager);
     $twigTemplateWrite->generateTemplate($pageTree, $theme, $options)->writeTemplate(vfsStream::url('root'));
     $this->assertEquals($expectedResult, $twigTemplateWrite->getTwigTemplate());
     $this->assertEquals($expectedResult, file_get_contents(vfsStream::url($filename)));
 }
 /**
  * Overrides the base renderSlot method
  */
 public function renderSlot($slotName = null, $extraAttributes = "")
 {
     $this->checkSlotName($slotName);
     try {
         $slotContents = array();
         $pageTree = $this->container->get('red_kite_cms.page_tree');
         $blockManagers = $pageTree->getBlockManagers($slotName);
         foreach ($blockManagers as $blockManager) {
             if (null === $blockManager) {
                 continue;
             }
             $slotContents[] = $this->renderBlock($blockManager, null, false, $extraAttributes);
         }
         if (empty($slotContents) && $pageTree->isCmsMode()) {
             $slotContents[] = sprintf('<div data-editor="enabled" data-block-id="0" data-slot-name="%s" class="al-empty-slot-placeholer">%s</div>', $slotName, $this->translator->translate('twig_extension_empty_slot', array(), 'RedKiteCmsBundle'));
         }
         $content = implode(PHP_EOL, $slotContents);
         $content = TwigTemplateWriter::MarkSlotContents($slotName, $content);
     } catch (\Exception $ex) {
         $content = $this->translator->translate('twig_extension_slot_rendering_error', array('%slot_name%' => $slotName, '%error%' => $ex->getMessage()), 'RedKiteCmsBundle');
     }
     return sprintf('<div class="al_%s">%s</div>', $slotName, $content);
 }
Ejemplo n.º 3
0
 /**
  * @inheritdoc
  */
 protected function save(PageTree $pageTree, Theme $theme, array $options)
 {
     return $this->twigTemplateWriter->generateTemplate($pageTree, $theme, $options)->writeTemplate($options["deployDir"]);
 }