/**
  * load layout if result ist not terminated
  *
  * @param MvcEvent $e
  */
 public function loadLayout(MvcEvent $e)
 {
     /* @var $result ModelInterface */
     $result = $e->getViewModel();
     if (!$result->terminate()) {
         $this->layout->load();
     }
 }
 /**
  * set layout root and load layout
  *
  * @param MvcEvent $e
  */
 public function loadLayout(MvcEvent $e)
 {
     /* @var $root ModelInterface */
     $root = $e->getViewModel();
     if ($root->terminate()) {
         return;
     }
     $this->layout->setRoot($root);
     $this->layout->load();
 }
Example #3
0
 /**
  * collect data for zdt
  *
  * @param MvcEvent $mvcEvent
  * @return LayoutCollector
  */
 public function collect(MvcEvent $mvcEvent)
 {
     $layout = $mvcEvent->getViewModel();
     $blocks = [];
     foreach ($this->layout->getBlocks() as $blockName => $block) {
         $blocks[$blockName] = ['template' => $block->getTemplate(), 'capture_to' => $block->captureTo(), 'class' => get_class($block)];
     }
     $data = ['handles' => $this->updater->getHandles(true), 'layout_structure' => $this->updater->getLayoutStructure()->toArray(), 'blocks' => $blocks, 'layout_template' => $layout->getTemplate(), 'current_area' => $this->updater->getArea()];
     $this->data = $data;
     return $this;
 }
 /**
  *
  * @param MvcEvent $e
  */
 public function prepareActionViewModel(MvcEvent $e)
 {
     /* @var $result ModelInterface */
     $result = $e->getResult();
     if ($result instanceof ModelInterface) {
         if ($result->terminate()) {
             $result->setOption('has_parent', null);
         } else {
             $this->blockPool->add(LayoutInterface::BLOCK_ID_ACTION_RESULT, $result);
         }
     }
 }
Example #5
0
 public function setUp()
 {
     $eventManager = new EventManager();
     $this->layoutUpdater = new LayoutUpdater();
     $this->layoutUpdater->setEventManager($eventManager);
     $this->sm = Bootstrap::getServiceManager();
     $this->em = $eventManager;
     $this->blockPool = new BlockPool();
     $this->blockFactory = new BlockFactory([], new BlockManager(), $this->sm);
     $this->blocksGenerator = new BlocksGenerator($this->blockFactory, $this->blockPool);
     $this->layout = new Layout($this->layoutUpdater, $this->blockPool);
     $this->layout->attachGenerator(BlocksGenerator::NAME, $this->blocksGenerator);
 }
Example #6
0
 /**
  * collect data for zdt
  *
  * @param MvcEvent $mvcEvent
  * @return LayoutCollector
  */
 public function collect(MvcEvent $mvcEvent)
 {
     $layout = $mvcEvent->getViewModel();
     $blocks = [];
     foreach ($this->layout->getBlocks() as $blockId => $block) {
         if ($parentBlock = $block->getOption('parent')) {
             $captureTo = $parentBlock . '::' . $block->captureTo();
         } else {
             $captureTo = $block->captureTo();
         }
         $blocks[$blockId] = ['instance' => $block, 'template' => $this->resolveTemplate($block->getTemplate()), 'capture_to' => $captureTo, 'class' => get_class($block)];
     }
     $data = ['handles' => $this->updater->getHandles(true), 'layout_structure' => $this->updater->getLayoutStructure()->toArray(), 'blocks' => $blocks, 'layout_template' => $layout->getTemplate(), 'current_area' => $this->updater->getArea()];
     $this->data = $data;
     return $this;
 }
Example #7
0
 /**
  *
  * @param string $blockId
  * @return ModelInterface
  */
 public function __invoke($blockId)
 {
     return $this->blockPool->get($blockId);
 }
Example #8
0
 /**
  *
  * @param string $blockId
  * @return ModelInterface
  */
 public function __invoke($blockId)
 {
     return $this->layout->getBlock($blockId);
 }
Example #9
0
 /**
  * @inheritDoc
  */
 public function generate(array $generators = [])
 {
     $this->layout->generate($generators);
     return $this;
 }
Example #10
0
 /**
  *
  * @param ModelInterface $root
  * @return LayoutManager
  */
 public function setRoot(ModelInterface $root)
 {
     $this->layout->setRoot($root);
     return $this;
 }