예제 #1
0
 /**
  * @param ContainerInterface $container
  * @param $requestedName
  * @param array $options
  * @return Layout
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $layout = new Layout($container->get(LayoutUpdaterInterface::class), $container->get(BlockPoolInterface::class));
     /** @var ModuleOptions $moduleOptions */
     $moduleOptions = $container->get(ModuleOptions::class);
     foreach ($moduleOptions->getGenerators() as $name => $specs) {
         $generator = $container->get($specs['class']);
         $layout->attachGenerator($name, $generator, $specs['priority']);
     }
     return $layout;
 }
예제 #2
0
 public function testInjectBlocks()
 {
     $layout = new Layout($this->updaterMock, $this->blockPool);
     $layout->attachGenerator('blocks', $this->blocksGenerator);
     $layoutModel = new ViewModel();
     $layout->setRoot($layoutModel);
     $layout->load();
     $this->assertEquals('new/layout', $layoutModel->getTemplate());
     $this->assertCount(3, $layoutModel->getChildren());
     $this->assertCount(1, $layout->getBlock('widget.1')->getChildren());
 }
예제 #3
0
 public function setUp()
 {
     $updater = new LayoutUpdater();
     $this->updater = $updater;
     $layout = new Layout(new BlockFactory(), $updater);
     $this->layout = $layout;
     $layout->addBlock('test-block', (new ViewModel())->setTemplate('widget1'));
     $renderer = new BlockRenderer();
     $renderer->setResolver($this->getResolver());
     $this->renderer = $renderer;
     $this->layoutManager = new LayoutManager($layout, $updater, $renderer);
 }
예제 #4
0
 public function testIsAllowed()
 {
     $layout = new Layout($this->blockFactory, $this->updaterMock);
     $layout->getEventManager()->getSharedManager()->attach('ConLayout\\Layout\\Layout', 'isAllowed', function ($e) {
         $blockId = $e->getParam('block_id');
         if ($blockId === 'widget.1') {
             return false;
         }
         return true;
     });
     $layout->addBlock('mr.widget', new ViewModel());
     $root = new ViewModel();
     $layout->setRoot($root);
     $layout->load();
     $this->assertCount(2, $root->getChildren());
 }
예제 #5
0
 public function getCaptureTo(ModelInterface $block)
 {
     return parent::getCaptureTo($block);
 }