/** * {@inheritdoc} */ public function findContainer($code, PageInterface $page, BlockInterface $parentContainer = null) { $container = null; if ($parentContainer) { // parent container is set, nothing to find, don't need to loop across the // name to find the correct container (main template level) $container = $parentContainer; } // first level blocks are containers if (!$container && $page->getBlocks()) { foreach ($page->getBlocks() as $block) { if ($block->getSetting('code') == $code) { $container = $block; break; } } } if (!$container) { $container = $this->blockInteractor->createNewContainer(array('enabled' => true, 'page' => $page, 'code' => $code, 'position' => 1, 'parent' => $parentContainer)); } return $container; }
/** * load the blocks of the $page * * @param \Sonata\PageBundle\Model\PageInterface $page */ public function loadBlocks(PageInterface $page) { $i = new RecursiveBlockIterator($page->getBlocks()); foreach ($i as $block) { $this->blocks[$block->getId()] = $block; } }
/** * load the blocks of the $page * * @param \Sonata\PageBundle\Model\PageInterface $page */ private function loadBlocks(PageInterface $page) { $i = new \RecursiveIteratorIterator(new RecursiveBlockIterator($page->getBlocks()), \RecursiveIteratorIterator::SELF_FIRST); foreach ($i as $block) { $this->blocks[$block->getId()] = $block; } }