LazyListener
in package
Lazy listener instance.
Used to allow lazy creation of listeners via a dependency injection container.
Lazy listener definitions have the following members:
- listener: the service name of the listener to use.
- method: the method name of the listener to invoke for the specified event.
If desired, you can pass $env at instantiation; this will be passed to the
container's build()
method, if it has one, when creating the listener
instance.
Pass instances directly to the event manager's attach()
method as the
listener argument.
Table of Contents
- $container : ContainerInterface
- $env : array<string|int, mixed>
- $listener : callable
- $method : string
- $service : string
- __construct() : mixed
- __invoke() : callable
- Use the listener as an invokable, allowing direct attachment to an event manager.
- fetchListener() : callable
Properties
$container
private
ContainerInterface
$container
Container from which to pull listener.
$env
private
array<string|int, mixed>
$env
Variables/options to use during service creation, if any.
$listener
private
callable
$listener
Marshaled listener callback.
$method
private
string
$method
Method name to invoke on listener.
$service
private
string
$service
Service name of listener.
Methods
__construct()
public
__construct(array<string|int, mixed> $definition, ContainerInterface $container[, array<string|int, mixed> $env = [] ]) : mixed
Parameters
- $definition : array<string|int, mixed>
- $container : ContainerInterface
- $env : array<string|int, mixed> = []
Return values
mixed —__invoke()
Use the listener as an invokable, allowing direct attachment to an event manager.
public
__invoke(EventInterface $event) : callable
Parameters
- $event : EventInterface
Return values
callable —fetchListener()
private
fetchListener() : callable