コード例 #1
0
 /**
  * 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);
 }