eZ\Publish\Core\MVC\Symfony\Controller\PageController::viewBlock PHP Метод

viewBlock() публичный Метод

Render the block.
public viewBlock ( Block $block, array $params = [], array $cacheSettings = [] ) : Response
$block eZ\Publish\Core\FieldType\Page\Parts\Block
$params array
$cacheSettings array settings for the HTTP cache, 'smax-age' and 'max-age' are checked.
Результат Symfony\Component\HttpFoundation\Response
    public function viewBlock(Block $block, array $params = array(), array $cacheSettings = array())
    {
        $response = new Response();
        if ($this->getParameter('content.view_cache') === true) {
            $response->setPublic();
            if (isset($cacheSettings['smax-age']) && is_int($cacheSettings['smax-age'])) {
                $response->setSharedMaxAge((int) $cacheSettings['smax-age']);
            }
            if (isset($cacheSettings['max-age']) && is_int($cacheSettings['max-age'])) {
                $response->setMaxAge((int) $cacheSettings['max-age']);
            }
        }
        $response->setContent($this->viewManager->renderBlock($block, $params + array('pageService' => $this->pageService, 'valid_items' => $this->pageService->getValidBlockItems($block))));
        return $response;
    }

Usage Example

Пример #1
0
 public function viewBlock(Block $block, array $params = array(), array $cacheSettings = array())
 {
     // Inject valid items as ContentInfo objects if possible.
     if ($this->pageService instanceof CoreBundlePageService) {
         $params += array('valid_contentinfo_items' => $this->pageService->getValidBlockItemsAsContentInfo($block));
     }
     return parent::viewBlock($block, $params, $cacheSettings);
 }