Skip to content

[HttpKernel] Fix service arg resolver for controllers as array callables #24970

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

Closed

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

As spotted today during a Symfony 4 workshop at SymfonyCon Cluj, setting a controller as an array [SomeController::class, 'helloAction'] works, it is defined as a service, BUT the actions don't get the services as arguments. This is fixing it.

Copy link
Member

@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a test would be nice :)

@weaverryan
Copy link
Member

Aren't workshops useful?

And yea... this important class doesn't have a test at all yet. Maybe we should add one at lunch tomorrow ;)

@Simperfit
Copy link
Contributor

Simperfit commented Nov 15, 2017

@weaverryan Maybe we should keep that kind of contribution (the tests) for the hackday in 3 days ?

@sroze
Copy link
Contributor

sroze commented Nov 15, 2017

Created tests for the existing behaviour plus the failing test in here: #24972

@nicolas-grekas
Copy link
Member Author

Closing in favor of #24972

@nicolas-grekas nicolas-grekas deleted the fix-service-resolver branch November 15, 2017 11:31
nicolas-grekas added a commit that referenced this pull request Nov 16, 2017
…rray callables (sroze, nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[HttpKernel] Fix service arg resolver for controllers as array callables

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #24970
| License       | MIT
| Doc PR        | ø

Replacing #24970 as I can't push tests directly to @nicolas-grekas' PR.

> As spotted today during a Symfony 4 workshop at SymfonyCon Cluj, setting a controller as an array [SomeController::class, 'helloAction'] works, it is defined as a service, BUT the actions don't get the services as arguments. This is fixing it.

Commits
-------

fc3d3bb [HttpKernel] Fix service arg resolver for controllers as array callables
a9e9f36 Add service value resolver tests Prove that the service value resolver will not work with the array notation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants