Beispiel #1
0
 /**
  * @param Config $blocks
  * @param Config $references
  * @param string $parentId
  */
 private function generateBlocks(Config $blocks, Config $references = null, $parentId = null)
 {
     foreach ($blocks as $blockId => $specs) {
         if (null !== $references && ($blockReference = $references->get($blockId))) {
             $specs->merge($blockReference);
         }
         if ($this->isRemoved($specs)) {
             continue;
         }
         if ($children = $specs->get(self::INSTRUCTION_BLOCKS)) {
             $this->generateBlocks($children, $references, $blockId);
         }
         if ($block = $this->blockPool->get($blockId)) {
             $this->blockFactory->configure($block, $specs->toArray());
         } else {
             $block = $this->blockFactory->createBlock($blockId, $specs->toArray());
         }
         if (null !== $parentId) {
             $block->setOption('has_parent', true);
             if (!$block->getOption('parent')) {
                 $block->setOption('parent', $parentId);
             }
         }
         $this->blockPool->add($blockId, $block);
     }
 }
 public function testCreateBlockImpl()
 {
     $request = new Request();
     $renderer = new PhpRenderer();
     $this->sm->setService('Request', $request);
     $this->sm->setService('ViewRenderer', $renderer);
     $block = $this->factory->createBlock('test.block.impl', ['class' => BlockImpl::class]);
     $this->assertInstanceof(RequestInterface::class, $block->getRequest());
     $this->assertSame($request, $block->getRequest());
     $this->assertSame($renderer, $block->getView());
 }
 public function testCreateBlockImpl()
 {
     $request = new Request();
     $renderer = new PhpRenderer();
     $this->sm->setService('Request', $request);
     $this->sm->setService('ViewRenderer', $renderer);
     $block = $this->factory->createBlock('test.block.impl', ['class' => 'ConLayoutTest\\Block\\Factory\\BlockImpl']);
     $this->assertInstanceof('Zend\\Stdlib\\RequestInterface', $block->getRequest());
     $this->assertSame($request, $block->getRequest());
     $this->assertSame($renderer, $block->getView());
 }
Beispiel #4
0
 /**
  * generate blocks from array configuration
  *
  * @param array $blockConfig
  */
 protected function generateBlocks()
 {
     if (false === $this->blocksGenerated) {
         $blocks = $this->updater->getLayoutStructure()->get(LayoutUpdaterInterface::INSTRUCTION_BLOCKS, []);
         if ($blocks instanceof Config) {
             $blocks = $blocks->toArray();
         }
         foreach ($blocks as $blockId => $specs) {
             if ($this->isBlockRemoved($blockId)) {
                 continue;
             }
             $block = $this->blockFactory->createBlock($blockId, $specs);
             $this->addBlock($blockId, $block);
         }
         $this->blocksGenerated = true;
     }
 }