Exemplo n.º 1
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;
 }
Exemplo n.º 2
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;
 }
 /**
  *
  * @param ViewModel $block
  * @return array
  */
 private function getHandles(ViewModel $block)
 {
     $options = $block->getOption('esi');
     $optionHandles = isset($options['handles']) ? (array) $options['handles'] : [];
     $currentHandles = $this->layoutUpdater->getHandles(true);
     $handlesIndex = [];
     foreach ($currentHandles as $currentHandle) {
         $handlesIndex[$currentHandle->getName()] = $currentHandle->getPriority();
     }
     $handles = [];
     foreach ($optionHandles as $optionHandle) {
         $priority = isset($handlesIndex[$optionHandle]) ? $handlesIndex[$optionHandle] : 1;
         $handles[$optionHandle] = $priority;
     }
     return $handles;
 }
 public function testLayoutUpdaterContainsOnlyDefaultHandle()
 {
     $this->assertEquals(['default'], $this->updater->getHandles());
 }
Exemplo n.º 5
0
 public function testSetHandles()
 {
     $this->updater->setHandles([new Handle('handle-1', 5), new Handle('handle-2', 0), new Handle('handle-3', 2)]);
     $this->assertSame(['handle-2', 'handle-3', 'handle-1'], $this->updater->getHandles());
 }
Exemplo n.º 6
0
 public function getHandles($asObject = false)
 {
     return $this->updater->getHandles($asObject);
 }