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

Publish/Core/MVC/Symfony/Controller/Controller.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\MVC\Symfony\Controller;
8
9 use Symfony\Component\DependencyInjection\ContainerAwareInterface;
10 use Symfony\Component\DependencyInjection\ContainerAwareTrait;
11 use Symfony\Component\DependencyInjection\ContainerInterface;
12 use Symfony\Component\HttpFoundation\Response;
13 use eZ\Publish\Core\MVC\Symfony\Security\Authorization\Attribute as AuthorizationAttribute;
14
15 abstract class Controller implements ContainerAwareInterface
16 {
17 use ContainerAwareTrait;
18
27 public function getParameter($parameterName, $defaultValue = null)
28 {
29 if ($this->getConfigResolver()->hasParameter($parameterName)) {
30 return $this->getConfigResolver()->getParameter($parameterName);
31 }
32
33 return $defaultValue;
34 }
35
43 public function hasParameter($parameterName)
44 {
45 return $this->getConfigResolver()->hasParameter($parameterName);
46 }
47
51 public function getConfigResolver()
52 {
53 return $this->container->get('ezpublish.config.resolver');
54 }
55
65 public function render($view, array $parameters = [], Response $response = null)
66 {
67 if (!isset($response)) {
68 $response = new Response();
69 }
70
71 $response->setContent($this->getTemplateEngine()->render($view, $parameters));
72
73 return $response;
74 }
75
79 public function getTemplateEngine()
80 {
81 return $this->container->get('templating');
82 }
83
87 public function getLogger()
88 {
89 return $this->container->get('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE);
90 }
91
95 public function getRepository()
96 {
97 return $this->container->get('ezpublish.api.repository');
98 }
99
103 public function getRequest()
104 {
105 return $this->container->get('request_stack')->getCurrentRequest();
106 }
107
111 public function getEventDispatcher()
112 {
113 return $this->container->get('event_dispatcher');
114 }
115
123 public function isGranted(AuthorizationAttribute $attribute)
124 {
125 return $this->container->get('security.authorization_checker')->isGranted($attribute);
126 }
127 }
eZ\Publish\Core\MVC\Symfony\Controller\Controller
Definition: Publish/Core/MVC/Symfony/Controller/Controller.php:16
eZ\Publish\Core\MVC\Symfony\Controller\Controller\isGranted
isGranted(AuthorizationAttribute $attribute)
Checks if current user has granted access to provided attribute.
Definition: Publish/Core/MVC/Symfony/Controller/Controller.php:123
eZ\Publish\Core\MVC\Symfony\Controller\Controller\getEventDispatcher
getEventDispatcher()
Definition: Publish/Core/MVC/Symfony/Controller/Controller.php:111
eZ\Publish\Core\MVC\Symfony\Controller\Controller\getRequest
getRequest()
Definition: Publish/Core/MVC/Symfony/Controller/Controller.php:103
eZ\Publish\Core\MVC\Symfony\Controller\Controller\getTemplateEngine
getTemplateEngine()
Definition: Publish/Core/MVC/Symfony/Controller/Controller.php:79
eZ\Publish\Core\MVC\Symfony\Controller\Controller\getLogger
getLogger()
Definition: Publish/Core/MVC/Symfony/Controller/Controller.php:87
eZ\Publish\Core\MVC\Symfony\Controller\Controller\hasParameter
hasParameter($parameterName)
Checks if $parameterName is defined.
Definition: Publish/Core/MVC/Symfony/Controller/Controller.php:43
eZ\Publish\Core\MVC\Symfony\Controller\Controller\getRepository
getRepository()
Definition: Publish/Core/MVC/Symfony/Controller/Controller.php:95
eZ\Publish\Core\MVC\Symfony\Controller\Controller\getConfigResolver
getConfigResolver()
Definition: Publish/Core/MVC/Symfony/Controller/Controller.php:51
eZ\Publish\Core\MVC\Symfony\Controller\Controller\getParameter
getParameter($parameterName, $defaultValue=null)
Returns value for $parameterName and fallbacks to $defaultValue if not defined.
Definition: Publish/Core/MVC/Symfony/Controller/Controller.php:27
eZ\Publish\Core\MVC\Symfony\Controller\Controller\render
render($view, array $parameters=[], Response $response=null)
Renders a view.
Definition: Publish/Core/MVC/Symfony/Controller/Controller.php:65
eZ\Publish\Core\MVC\Symfony\Security\Authorization\Attribute
Authorization attribute class to be used with SecurityContextInterface::isGranted().
Definition: Attribute.php:31
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.