public function ContainerAwareEventDispatcher::addSubscriberService in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php \Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher::addSubscriberService()
Adds a service as event subscriber.
Parameters
string $serviceId The service ID of the subscriber service:
string $class The service's class name (which must implement EventSubscriberInterface):
File
- vendor/
symfony/ event-dispatcher/ ContainerAwareEventDispatcher.php, line 140
Class
- ContainerAwareEventDispatcher
- Lazily loads listeners and subscribers from the dependency injection container.
Namespace
Symfony\Component\EventDispatcherCode
public function addSubscriberService($serviceId, $class) {
foreach ($class::getSubscribedEvents() as $eventName => $params) {
if (is_string($params)) {
$this->listenerIds[$eventName][] = array(
$serviceId,
$params,
0,
);
}
elseif (is_string($params[0])) {
$this->listenerIds[$eventName][] = array(
$serviceId,
$params[0],
isset($params[1]) ? $params[1] : 0,
);
}
else {
foreach ($params as $listener) {
$this->listenerIds[$eventName][] = array(
$serviceId,
$listener[0],
isset($listener[1]) ? $listener[1] : 0,
);
}
}
}
}