8000 Added missing kernel.event_subscriber tag (closes #2012) by jalliot · Pull Request #2021 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Added missing kernel.event_subscriber tag (closes #2012) #2021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 29, 2011
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Backported new behaviour from PR #2148 and removed check for interfac…
…e at run-time
  • Loading branch information
jalliot committed Sep 29, 2011
commit 21cf0ac5d73da703db70c3ed09959d9a781233c1
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,20 @@ public function getListeners($eventName = null)
/**
* Adds a service as event subscriber
*
* If this service is created by a factory, its class value must be correctly filled.
* The service's class must implement Symfony\Component\EventDispatcher\EventSubscriberInterface.
*
* @param string $serviceId The service ID of the subscriber service
* @param string $class The service's class name
* @param string $class The service's class name (which must implement EventSubscriberInterface)
*/
public function addSubscriberService($serviceId, $class)
{
$refClass = new \ReflectionClass($class);
$interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
if (!$refClass->implementsInterface($interface)) {
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $serviceId, $interface));
}

foreach ($class::getSubscribedEvents() as $eventName => $params) {
if (is_string($params)) {
$this->listenerIds[$eventName][] = array($serviceId, $params, 0);
} else {
} elseif (is_string($params[0])) {
$this->listenerIds[$eventName][] = array($serviceId, $params[0], $params[1]);
} else {
foreach ($params as $listener) {
$this->listenerIds[$eventName][] = array($serviceId, $listener[0], isset($listener[1]) ? $listener[1] : 0);
}
}
}
}
Expand Down
0