Skip to content

[RFC] Why RegisterListenersPass does not complain when the EventDispatcher is missing? #23265

@Jean85

Description

@Jean85
Q A
Bug report? no
Feature request? no
BC Break report? no
RFC? yes
Symfony version all

Today I struggled a lot with a stupid bug, because I was using the RegisterListenersPass, and I was passing the wrong service name for the EventDispatcher. If the container complainer with a ServiceNotFoundException I would have catched that issue days ago! There's a reason behind this? Could we make this change?

// Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass

    public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) {
-            return;
+           throw new ServiceNotFoundException($this->dispatcherService);
    }

Obviously we can think of a more convoluted solution, but still this issue remains, IMHO. And 4.x is coming, so a BC wouldn't be an issue here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EventDispatcherRFCRFC = Request For Comments (proposals about features that you want to be discussed)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions