$extractingDispatcher =
new ExtractingEventDispatcher();
foreach ($container->
findTaggedServiceIds('kernel.event_subscriber', true
) as $id =>
$tags) { $def =
$container->
getDefinition($id);
// We must assume that the class value has been correctly filled, even if the service is created by a factory
$class =
$def->
getClass();
if (!
$r =
$container->
getReflectionClass($class)) { throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.',
$class,
$id));
} if (!
$r->
isSubclassOf(EventSubscriberInterface::
class)) { throw new InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".',
$id, EventSubscriberInterface::
class));
} $class =
$r->name;
$dispatcherDefinitions =
[];
foreach ($tags as $attributes) { if (!
isset($attributes['dispatcher'
]) ||
isset($dispatcherDefinitions[$attributes['dispatcher'
]])) { continue;
} $dispatcherDefinitions[$attributes['dispatcher'
]] =
$container->
findDefinition($attributes['dispatcher'
]);
}