|
@@ -12,6 +12,10 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
|
{
|
|
{
|
|
$listeners = array();
|
|
$listeners = array();
|
|
foreach ($container->findTaggedServiceIds('jms_serializer.event_listener') as $id => $tags) {
|
|
foreach ($container->findTaggedServiceIds('jms_serializer.event_listener') as $id => $tags) {
|
|
|
|
+ if (!$container->getDefinition($id)->isPublic()) {
|
|
|
|
+ throw new \RuntimeException(sprintf('The tag "jms_serializer.event_listener" of service "%s" requires the service to be public.', $id));
|
|
|
|
+ }
|
|
|
|
+
|
|
foreach ($tags as $attributes) {
|
|
foreach ($tags as $attributes) {
|
|
if ( ! isset($attributes['event'])) {
|
|
if ( ! isset($attributes['event'])) {
|
|
throw new \RuntimeException(sprintf('The tag "jms_serializer.event_listener" of service "%s" requires an attribute named "event".', $id));
|
|
throw new \RuntimeException(sprintf('The tag "jms_serializer.event_listener" of service "%s" requires an attribute named "event".', $id));
|
|
@@ -27,11 +31,16 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
|
}
|
|
}
|
|
|
|
|
|
foreach ($container->findTaggedServiceIds('jms_serializer.event_subscriber') as $id => $tags) {
|
|
foreach ($container->findTaggedServiceIds('jms_serializer.event_subscriber') as $id => $tags) {
|
|
- $subscriberClass = $container->getDefinition($id)->getClass();
|
|
|
|
|
|
+ $subscriberDefinition = $container->getDefinition($id);
|
|
|
|
+ $subscriberClass = $subscriberDefinition->getClass();
|
|
if ( ! is_subclass_of($subscriberClass, 'JMS\SerializerBundle\Serializer\EventDispatcher\EventSubscriberInterface')) {
|
|
if ( ! is_subclass_of($subscriberClass, 'JMS\SerializerBundle\Serializer\EventDispatcher\EventSubscriberInterface')) {
|
|
throw new \RuntimeException(sprintf('The service "%s" (class: %s) does not implement the EventSubscriberInterface.', $id, $subscriberClass));
|
|
throw new \RuntimeException(sprintf('The service "%s" (class: %s) does not implement the EventSubscriberInterface.', $id, $subscriberClass));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (!$subscriberDefinition->isPublic()) {
|
|
|
|
+ throw new \RuntimeException(sprintf('The tag "jms_serializer.event_listener" of service "%s" requires the service to be public.', $id));
|
|
|
|
+ }
|
|
|
|
+
|
|
foreach (call_user_func(array($subscriberClass, 'getSubscribedEvents')) as $eventData) {
|
|
foreach (call_user_func(array($subscriberClass, 'getSubscribedEvents')) as $eventData) {
|
|
if ( ! isset($eventData['event'])) {
|
|
if ( ! isset($eventData['event'])) {
|
|
throw new \RuntimeException(sprintf('The service "%s" (class: %s) must return an event for each subscribed event.', $id, $subscriberClass));
|
|
throw new \RuntimeException(sprintf('The service "%s" (class: %s) must return an event for each subscribed event.', $id, $subscriberClass));
|