Adds a service as event subscriber
string $serviceId The service ID of the subscriber service:
string $class The service's class name (which must implement EventSubscriberInterface):
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,
);
}
}
}
}