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

ValueObjectsIds.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\MVC\Symfony\View\ParametersInjector;
8
9 use eZ\Publish\API\Repository\Values\Content\Location;
10 use eZ\Publish\Core\MVC\Symfony\View;
11 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
12
18 class ValueObjectsIds implements EventSubscriberInterface
19 {
20 public static function getSubscribedEvents()
21 {
22 return [View\ViewEvents::FILTER_VIEW_PARAMETERS => 'injectValueObjectsIds'];
23 }
24
25 public function injectValueObjectsIds(View\Event\FilterViewParametersEvent $event)
26 {
27 $view = $event->getView();
28 $parameterBag = $event->getParameterBag();
29
30 if ($view instanceof View\LocationValueView) {
31 if (($location = $view->getLocation()) instanceof Location) {
32 $parameterBag->set('locationId', $location->id);
33 }
34 }
35 if ($view instanceof View\ContentValueView) {
36 $parameterBag->set('contentId', $view->getContent()->id);
37 }
38 if ($view instanceof View\BlockValueView) {
39 $parameterBag->set('blockId', $view->getBlock()->id);
40 }
41 }
42 }
eZ\Publish\API\Repository\Values\Content\Location
Definition: API/Repository/Values/Content/Location.php:32
eZ\Publish\Core\MVC\Symfony\View\Event\FilterViewParametersEvent
Dispatched when the parameters injected into a view are collected.
Definition: FilterViewParametersEvent.php:19
eZ\Publish\Core\MVC\Symfony\View\ParametersInjector\ValueObjectsIds
Injects the ID of the view's value objects as view parameters.
Definition: ValueObjectsIds.php:19
eZ\Publish\Core\MVC\Symfony\View\ParametersInjector\ValueObjectsIds\getSubscribedEvents
static getSubscribedEvents()
Definition: ValueObjectsIds.php:20
eZ\Publish\Core\MVC\Symfony\View\ParametersInjector\ValueObjectsIds\injectValueObjectsIds
injectValueObjectsIds(View\Event\FilterViewParametersEvent $event)
Definition: ValueObjectsIds.php:25
eZ\Publish\Core\MVC\Symfony\View\ViewEvents\FILTER_VIEW_PARAMETERS
const FILTER_VIEW_PARAMETERS
Dispatched before ViewParameters are injected into a View to collect the view parameters.
Definition: ViewEvents.php:30
eZ\Publish\Core\MVC\Symfony\View\BlockValueView
Definition: BlockValueView.php:12
eZ\Publish\Core\MVC\Symfony\View\ContentValueView
A view that contains a Content.
Definition: ContentValueView.php:13
eZ\Publish\Core\MVC\Symfony\View\LocationValueView
Definition: LocationValueView.php:10
eZ\Publish\Core\MVC\Symfony\View\ParametersInjector
Collects parameters that will be injected into View objects.
Definition: ParametersInjector.php:13
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\Publish\Core\MVC\Symfony\View
Definition: BaseView.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.