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
Symfony\Component\DependencyInjection\ContainerInterface $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
string $eventName Event for which the listener is added
- $callback
array $callback The service ID of the listener service & the method name that has
to be called
- $priority
integer $priority The higher this value, the earlier an event listener will be triggered
in the chain. Defaults to 0.
Throws
|
public
|
#
removeListener( string|array $eventName, callable $listener )
Parameters
- $eventName
string|array $eventName The event(s) to remove a listener from
- $listener
callable $listener The listener to remove
See
Overrides
|
public
Boolean
|
#
hasListeners( string $eventName = null )
Parameters
- $eventName
string $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
string $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
string $serviceId The service ID of the subscriber service
- $class
string $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
string $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
Symfony\Component\EventDispatcher\Event
$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
string $eventName The name of the event to dispatch. The name of the event is the name
of the method that is invoked on listeners.
|