Skip to content

[FrameworkBundle] Improve DX of RedirectController #25259

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
wants to merge 1 commit into from

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Dec 1, 2017

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #...
License MIT
Doc PR todo

Similar to #24637 but for redirect controller.

TODO:

  • Add tests

@dunglas
Copy link
Member Author

dunglas commented Dec 2, 2017

Status: needs review

@ro0NL
Copy link
Contributor

ro0NL commented Dec 2, 2017

isnt adding a single test to cover the method forwarding simpler?

@dunglas
Copy link
Member Author

dunglas commented Dec 2, 2017

Well doing that allowed me to find some bugs in my forwarding logic. So I would prefer to keep al the tests.

@sroze
Copy link
Contributor

sroze commented Dec 3, 2017

Maybe that's not that useful if we go with this PR that allows redirection to be set directly in the routing configuration?
#25145

@dunglas
Copy link
Member Author

dunglas commented Dec 3, 2017

@sroze IMO we must have an invoke method for all builtin controllers.


public function __invoke(Request $request): Response
{
if (null !== $route = $request->attributes->get('route')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

That looks like alot of magic. It might be cleaner to just create a new controller with invoke for one action. And possibly deprecate it in RedirectController so there is no ambiguity.

fabpot added a commit that referenced this pull request Jan 19, 2018
This PR was merged into the 4.1-dev branch.

Discussion
----------

[DI] Allow for invokable event listeners

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

Inspired by #24637 / #25259. This adds invokable support for event listeners :)

```yaml
Some\Foo:
    tags: [{ name: kernel.event_listener, event: kernel.request }]
```

```php
class Foo {
    public function __invoke(GetResponseEvent $event) { }
}
```

Commits
-------

fa5b7eb [DI] Allow for invokable event listeners
@nicolas-grekas
Copy link
Member

I'm not convinced this provides anything. Actually, I'm much more convinced by the aliasing discussed in #25145 (comment)

👎

@fabpot
Copy link
Member

fabpot commented Mar 27, 2018

I don't see why we must provide an __invoke method for all built-in controllers. I think DX would be much more improved if we would not have to use the FQCN instead.
👎

@nicolas-grekas nicolas-grekas modified the milestones: 4.1, next Apr 20, 2018
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.1 Nov 1, 2018
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.

8 participants