Class ContainerAwareEventDispatcher
Lazily loads listeners and subscribers from the dependency injection
container.
-
Symfony\Component\EventDispatcher\EventDispatcher
implements
Symfony\Component\EventDispatcher\EventDispatcherInterface
-
Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher
Methods summary
public
|
#
__construct( Symfony\Component\DependencyInjection\ContainerInterface $container )
Constructor.
Parameters
- $container
- A ContainerInterface instance
|
public
|
#
addListenerService( string $eventName, array $callback, integer $priority = 0 )
Adds a service as event listener.
Adds a service as event listener.
Parameters
- $eventName
- Event for which the listener is added
- $callback
The service ID of the listener service & the method
name that has to be called
- $priority
The higher this value, the earlier an event listener
will be triggered in the chain.
Defaults to 0.
Throws
|
public
|
#
removeListener( string $eventName, callable $listener )
Parameters
- $eventName
- The event to remove a listener from
- $listener
- The listener to remove
See
Overrides
|
public
boolean
|
#
hasListeners( string $eventName = null )
Parameters
- $eventName
- The name of the event
Returns
boolean true if the specified event has any listeners, false otherwise
See
Overrides
|
public
array
|
#
getListeners( string $eventName = null )
Parameters
- $eventName
- The name of the event
Returns
array The event listeners for the specified event, or all event listeners by event name
See
Overrides
|
public
|
#
addSubscriberService( string $serviceId, string $class )
Adds a service as event subscriber.
Adds a service as event subscriber.
Parameters
- $serviceId
- The service ID of the subscriber service
- $class
- The service's class name (which must implement EventSubscriberInterface)
|
public
Symfony\Component\EventDispatcher\Event
|
#
dispatch( string $eventName, Symfony\Component\EventDispatcher\Event $event = null )
Lazily loads listeners for this event from the dependency injection
container.
Parameters
- $eventName
The name of the event to dispatch. The name of
the event is the name of the method that is
invoked on listeners.
- $event
The event to pass to the event handlers/listeners.
If not supplied, an empty Event instance is created.
Returns
Throws
Overrides
|
public
|
|
protected
|
#
lazyLoad( string $eventName )
Lazily loads listeners for this event from the dependency injection
container.
Lazily loads listeners for this event from the dependency injection
container.
Parameters
- $eventName
The name of the event to dispatch. The name of
the event is the name of the method that is
invoked on listeners.
|