TemplateListener
in package
implements
EventSubscriberInterface, ServiceSubscriberInterface
Handles the Template annotation for actions.
Depends on pre-processing of the ControllerListener.
Tags
Interfaces, Classes, Traits and Enums
- EventSubscriberInterface
- An EventSubscriber knows itself what events it is interested in.
- ServiceSubscriberInterface
- A ServiceSubscriber exposes its dependencies via the static {@link getSubscribedServices} method.
Table of Contents
- $container : mixed
- $templateGuesser : mixed
- $twig : mixed
- __construct() : mixed
- getSubscribedEvents() : array<string, mixed>
- Returns an array of event names this subscriber wants to listen to.
- getSubscribedServices() : array<string|int, string>
- Returns an array of service types required by such instances, optionally keyed by the service names used internally.
- onKernelController() : mixed
- Guesses the template name to render and its variables and adds them to the request object.
- onKernelView() : mixed
- Renders the template and initializes a new response object with the rendered template content.
- setContainer() : void
- resolveDefaultParameters() : mixed
Properties
$container
private
mixed
$container
$templateGuesser
private
mixed
$templateGuesser
$twig
private
mixed
$twig
Methods
__construct()
public
__construct(TemplateGuesser $templateGuesser[, Environment $twig = null ]) : mixed
Parameters
- $templateGuesser : TemplateGuesser
- $twig : Environment = null
Return values
mixed —getSubscribedEvents()
Returns an array of event names this subscriber wants to listen to.
public
static getSubscribedEvents() : array<string, mixed>
Return values
array<string, mixed> —The event names to listen to
getSubscribedServices()
Returns an array of service types required by such instances, optionally keyed by the service names used internally.
public
static getSubscribedServices() : array<string|int, string>
For mandatory dependencies:
- ['logger' => 'Psr\Log\LoggerInterface'] means the objects use the "logger" name internally to fetch a service which must implement Psr\Log\LoggerInterface.
- ['loggers' => 'Psr\Log\LoggerInterface[]'] means the objects use the "loggers" name internally to fetch an iterable of Psr\Log\LoggerInterface instances.
- ['Psr\Log\LoggerInterface'] is a shortcut for
- ['Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface']
otherwise:
- ['logger' => '?Psr\Log\LoggerInterface'] denotes an optional dependency
- ['loggers' => '?Psr\Log\LoggerInterface[]'] denotes an optional iterable dependency
- ['?Psr\Log\LoggerInterface'] is a shortcut for
- ['Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface']
Return values
array<string|int, string> —The required service types, optionally keyed by service names
onKernelController()
Guesses the template name to render and its variables and adds them to the request object.
public
onKernelController(KernelEvent $event) : mixed
Parameters
- $event : KernelEvent
Return values
mixed —onKernelView()
Renders the template and initializes a new response object with the rendered template content.
public
onKernelView(KernelEvent $event) : mixed
Parameters
- $event : KernelEvent
Return values
mixed —setContainer()
public
setContainer(ContainerInterface $container) : void
Parameters
- $container : ContainerInterface
Return values
void —resolveDefaultParameters()
private
resolveDefaultParameters(Request $request, Template $template, mixed $controller, mixed $action) : mixed
Parameters
- $request : Request
- $template : Template
- $controller : mixed
- $action : mixed