예제 #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);
     }
 }
예제 #2
0
 /**
  *
  * @return ModelInterface[]
  */
 public function getBlocks()
 {
     return $this->blockPool->get();
 }