Skip to content

Commit

Permalink
[FramworkBundle][HttpKernel] Check event listener services are not ab…
Browse files Browse the repository at this point in the history
…stract
  • Loading branch information
lyrixx committed Oct 4, 2013
1 parent 6fce9d8 commit 6744ead
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Expand Up @@ -30,6 +30,10 @@ public function process(ContainerBuilder $container)
throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event listeners are lazy-loaded.', $id));
}

if ($def->isAbstract()) {
throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as event listeners are lazy-loaded.', $id));
}

foreach ($events as $event) {
$priority = isset($event['priority']) ? $event['priority'] : 0;

Expand Down
Expand Up @@ -115,6 +115,20 @@ public function testPrivateEventSubscriber()
$registerListenersPass = new RegisterKernelListenersPass();
$registerListenersPass->process($container);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The service "foo" must not be abstract as event listeners are lazy-loaded.
*/
public function testAbstractEventListener()
{
$container = new ContainerBuilder();
$container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_listener', array());
$container->register('event_dispatcher', 'stdClass');

$registerListenersPass = new RegisterKernelListenersPass();
$registerListenersPass->process($container);
}
}

class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expand Down

0 comments on commit 6744ead

Please sign in to comment.