Class LazyListenerAggregate

Summary

Fully Qualified Name: Zend\EventManager\LazyListenerAggregate
Implements: ListenerAggregateInterface

Description

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

));

Methods

Name Description Defined By
__construct() Constructor LazyListenerAggregate
attach() Attach the aggregate to the event manager. LazyListenerAggregate

Method Details

__construct()

Constructor

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.

Parameter Name Type Description
$listeners
$container
$env

Returns:

attach()

Attach the aggregate to the event manager.

Loops through all composed lazy listeners, and attaches them to the event manager.

Parameter Name Type Description
$events
$priority

Returns:

Top