public function buildView(array $parameters) { $view = new BlockView(); if (isset($parameters['id'])) { $view->setBlock($this->pageService->loadBlock($parameters['id'])); } elseif ($parameters['block'] instanceof Block) { $view->setBlock($parameters['block']); } $this->viewConfigurator->configure($view); // deprecated controller actions are replaced with their new equivalent, viewAction if (!$view->getControllerReference() instanceof ControllerReference) { if (in_array($parameters['_controller'], ['ez_page:viewBlock', 'ez_page:viewBlockById'])) { $view->setControllerReference(new ControllerReference('ez_page:viewAction')); } } $this->viewParametersInjector->injectViewParameters($view, $parameters); return $view; }
/** * @param array $blockProperties * * @return \PHPUnit_Framework_MockObject_MockObject|\eZ\Publish\Core\MVC\Symfony\View\BlockView */ protected function getBlockView(array $blockProperties = array()) { $view = new BlockView(); $view->setViewType('full'); $view->setBlock(new Block($blockProperties)); return $view; }
/** * @param array $properties * * @return \PHPUnit_Framework_MockObject_MockObject */ protected function getBlockMock(array $properties = array()) { $view = new BlockView(); $view->setBlock(new Block($properties)); return $view; }
/** * Renders $block by selecting the right template. * $block will be injected in the selected template. * * @param \eZ\Publish\Core\FieldType\Page\Parts\Block $block * @param array $parameters Parameters to pass to the template called to * render the view. By default, it's empty. * 'block' entry is reserved for the Block that is viewed. * * @throws \RuntimeException * * @return string */ public function renderBlock(Block $block, $parameters = array()) { $view = new BlockView(null, $parameters); $view->setBlock($block); $this->viewConfigurator->configure($view); if ($view->getTemplateIdentifier() === null) { throw new RuntimeException("Unable to find a view for location #{$block->id}"); } return $this->renderContentView($view); }