Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

ViewRendererListener.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Bundle\EzPublishCoreBundle\EventListener;
8
9 use eZ\Publish\Core\MVC\Symfony\View\Renderer as ViewRenderer;
10 use eZ\Publish\Core\MVC\Symfony\View\View;
11 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
12 use Symfony\Component\HttpFoundation\Response;
13 use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
14 use Symfony\Component\HttpKernel\KernelEvents;
15
16 class ViewRendererListener implements EventSubscriberInterface
17 {
19 private $viewRenderer;
20
21 public function __construct(ViewRenderer $viewRenderer)
22 {
23 $this->viewRenderer = $viewRenderer;
24 }
25
26 public static function getSubscribedEvents()
27 {
28 return [KernelEvents::VIEW => 'renderView'];
29 }
30
31 public function renderView(GetResponseForControllerResultEvent $event)
32 {
33 if (!($view = $event->getControllerResult()) instanceof View) {
34 return;
35 }
36
37 if (!($response = $view->getResponse()) instanceof Response) {
38 $response = new Response();
39 }
40
41 $response->setContent($this->viewRenderer->render($view));
42
43 $event->setResponse($response);
44 }
45 }
eZ\Bundle\EzPublishCoreBundle\EventListener\ViewRendererListener
Definition: ViewRendererListener.php:17
eZ\Bundle\EzPublishCoreBundle\EventListener\ViewRendererListener\renderView
renderView(GetResponseForControllerResultEvent $event)
Definition: ViewRendererListener.php:31
eZ\Bundle\EzPublishCoreBundle\EventListener\ViewRendererListener\__construct
__construct(ViewRenderer $viewRenderer)
Definition: ViewRendererListener.php:21
eZ\Bundle\EzPublishCoreBundle\EventListener\ViewRendererListener\$viewRenderer
$viewRenderer
Definition: ViewRendererListener.php:19
eZ\Bundle\EzPublishCoreBundle\EventListener\ViewRendererListener\getSubscribedEvents
static getSubscribedEvents()
Definition: ViewRendererListener.php:26
eZ\Publish\Core\MVC\Symfony\View\View
Main interface for Views of Value objects (content, block...).
Definition: Publish/Core/MVC/Symfony/View/View.php:16
eZ\Bundle\EzPublishCoreBundle\EventListener
Definition: BackgroundIndexingTerminateListener.php:7
eZ\Publish\Core\MVC\Symfony\View\Renderer
Definition: TemplateRenderer.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.