public function ContainerAwareEventDispatcher::addListenerService in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php \Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher::addListenerService()
Adds a service as event listener.
Parameters
string $eventName Event for which the listener is added:
array $callback The service ID of the listener service & the method: name that has to be called
int $priority The higher this value, the earlier an event listener: will be triggered in the chain. Defaults to 0.
Throws
\InvalidArgumentException
File
- vendor/
symfony/ event-dispatcher/ ContainerAwareEventDispatcher.php, line 69
Class
- ContainerAwareEventDispatcher
- Lazily loads listeners and subscribers from the dependency injection container.
Namespace
Symfony\Component\EventDispatcherCode
public function addListenerService($eventName, $callback, $priority = 0) {
if (!is_array($callback) || 2 !== count($callback)) {
throw new \InvalidArgumentException('Expected an array("service", "method") argument');
}
$this->listenerIds[$eventName][] = array(
$callback[0],
$callback[1],
$priority,
);
}