FileAccess Orion

LazyListenerAggregate
in package
implements ListenerAggregateInterface Uses ListenerAggregateTrait

Aggregate listener for attaching lazy listeners.

Lazy listeners are listeners where creation is deferred until they are triggered; this removes the most costly mechanism of pulling a listener from a container unless the listener is actually invoked.

Usage is:

$events->attachAggregate(new LazyListenerAggregate( $lazyEventListenersOrDefinitions, $container ));

Interfaces, Classes, Traits and Enums

ListenerAggregateInterface
Interface for self-registering event listeners.

Table of Contents

$listeners  : array<string|int, callable>
$container  : ContainerInterface
$env  : array<string|int, mixed>
$lazyListeners  : array<string|int, LazyEventListener>
Generated LazyEventListener instances.
__construct()  : mixed
Constructor
attach()  : void
Attach the aggregate to the event manager.
detach()  : mixed
{@inheritDoc}

Properties

$env

private array<string|int, mixed> $env

Additional environment/option variables to use when creating listener.

Methods

__construct()

Constructor

public __construct(array<string|int, mixed> $listeners, ContainerInterface $container[, array<string|int, mixed> $env = [] ]) : mixed

Accepts the composed $listeners, as well as the $container and $env in order to create a listener aggregate that defers listener creation until the listener is triggered.

Listeners may be either LazyEventListener instances, or lazy event listener definitions that can be provided to a LazyEventListener constructor in order to create a new instance; in the latter case, the $container and $env will be passed at instantiation as well.

Parameters
$listeners : array<string|int, mixed>
$container : ContainerInterface
$env : array<string|int, mixed> = []
Tags
throws
InvalidArgumentException

for invalid listener items.

Return values
mixed

Search results