Skip to content
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

[FrameworkBundle][HttpKernel] Provide intuitive error message when a controller fails because it's not registered as a service #30569

Open
wants to merge 5 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@moynzzz
Copy link
Contributor

moynzzz commented Mar 14, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #27787, symfony/symfony-docs#7988
License MIT
Doc PR none

Create a very late controller argument value resolver to throw an intuitive error message when controller fails because it is not registered as a service.

Create a very late controller argument value resolver to throw an int…
…uitive error message when controller fails because it is not registered as a service.
@nicolas-grekas
Copy link
Member

nicolas-grekas left a comment

Nice, thanks! Here are some comments and proposals.

@nicolas-grekas nicolas-grekas changed the title [WIP][FrameworkBundle][HttpKernel] Provide intuitive error message when a controller fails because it's not registered as a service [FrameworkBundle][HttpKernel] Provide intuitive error message when a controller fails because it's not registered as a service Mar 20, 2019

@@ -51,6 +51,11 @@
<tag name="controller.argument_value_resolver" priority="-150" />
</service>

<service id="argument_resolver.not_tagged_controller" class="Symfony\Component\HttpKernel\Controller\ArgumentResolver\ControllerNotRegisteredAsServiceValueResolver">

This comment has been minimized.

@fabpot

fabpot Mar 20, 2019

Member

I would only enable this resolver when debug is true.

This comment has been minimized.

@moynzzz

moynzzz Mar 20, 2019

Author Contributor

I added the registration of the NotTaggedControllerValueResolver resolver service to the Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass.

if ($container->getParameter('kernel.debug')) {
$container->register($this->notTaggedControllerResolverServiceId, NotTaggedControllerValueResolver::class);
$resolvers[] = new Reference($this->notTaggedControllerResolverServiceId);
}

This comment has been minimized.

@fabpot

fabpot Mar 21, 2019

Member

I would not register it this way. Instead, what about moving the definition in the src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml file instead?

This comment has been minimized.

@moynzzz

moynzzz Mar 21, 2019

Author Contributor

Registration of resolver moved to src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml.

moynzzz added some commits Mar 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.