8000 [FramworkBundle] Check event listener services are not abstract by lyrixx · Pull Request #9214 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FramworkBundle] Check event listener services are not abstract #9214

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 1 commit into from
Oct 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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