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][Routing] added Configurators to handle template and redirect controllers #30501

Merged
merged 1 commit into from Feb 9, 2020

Conversation

HeahDude
Copy link
Contributor

@HeahDude HeahDude commented Mar 9, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? let's see
Fixed tickets partially #24640, #25145
License MIT
Doc PR symfony/symfony-docs#11120

While working on symfony/symfony-docs#11085, I felt bad about the long notations required for simple redirects and templates rendering template actions, but I love and use those features since always. Then I gave it a try yesterday night and now I realised I missed #24640 and that #25145 has been closed x).

So here we go, here's my WIP. WDYT of this implementation? ping @javiereguiluz?

I'm going to open the PR in the docs so we can discuss the DX changes there too, and keep focus on the code here.

Cheers!

EDIT

This PR now only update PHP-DSL configurators.


TODO:

@HeahDude
Copy link
Contributor Author

HeahDude commented Mar 9, 2019

I'd really appreciate some help if anyone had already overridden some xsd schema thanks!

@HeahDude
Copy link
Contributor Author

I've updated symfony/symfony-docs#11120 with a nice before/after view.

Also I need to rebase on top of #30507.

Xml config is working properly, but the IDE cannot resolve validation/autocompletion yet, this works thanks to the loader using its constant local path.
I guess we need to create a new path on https://symfony.com/routing that we need to declare explicitly in config/routes.xml or any xml file where this feature should be used, are you the one handling this @fabpot? Can you help me on this?

Apart this last points, the feature is ready from side, only reviews needed now :), thanks!

@javiereguiluz
Copy link
Member

Thanks for working on this. To make this feature completely self-explanatory, I think we should rename redirect-to as redirect-to-route (we already have redirect-to-url). What do you think?

fabpot added a commit that referenced this pull request Mar 11, 2019
This PR was merged into the 3.4 branch.

Discussion
----------

[Routing] Fixed XML options resolution

| 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        | ~

Found this bug while adding tests in #30501. I need it to be merged upward so it can get green there.
Thanks!

Commits
-------

53a6ff8 [Routing] Fixed XML options resolution
@HeahDude HeahDude changed the title [FrameworkBundle][Routing] added a RoutingConfigurator to handle template and redirect [FrameworkBundle][Routing] added proper Loader namespace to handle controllers Mar 13, 2019
fabpot added a commit that referenced this pull request Mar 20, 2019
… "format" in configuration (Jules Pietri)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[Routing] Exposed "utf8" option, defaults "locale" and "format" in configuration

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | symfony/symfony-docs#11126

A sibling to #30501, everything is in the title :).

Commits
-------

2911490 [Routing] Exposed "utf8" option, defaults "locale" and "format" in configuration
@HeahDude
Copy link
Contributor Author

Rebased and squashed here, while I addressed @javiereguiluz's comment.

Also, I was not happy with the xml definition because all attributes are there and it's hard to guess which one to use in which context, so I propose to use dedicated types instead: https://github.com/symfony/symfony/compare/a46c76a8c3a05adb7f984ea4d9cffbd3a446f3f5..7055ba0a5b09cec84d88f5c0447e79b65aa48a85#diff-96d406b9b38189be981bbea1bad334bd.

Tests are passing locally and on travis, but not on windows.. I wonder how this line https://github.com/symfony/symfony/pull/30501/files#diff-44f544990841fe196e4ea5c76dcc18dfR8 can be a problem, if anyone has a clue on that topic that would be awesome.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Dec 8, 2019

Did you consider this instead for the PHP-DSL?

    $routes->add('template_route', '/static')
        ->template('static.html.twig')
        ->maxAge(300)
        ->sharedMaxAge(100)
        ->private(true)
        ->methods(['GET'])
        ->options(['utf8' => true])
        ->condition('abc')
    ;
    $routes->add('redirect_route', '/redirect')
        ->redirectToRoute('target_route')
        ->permanent(true)
        ->ignoreAttributes(['attr', 'ibutes'])
        ->keepRequestMethod(true)
        ->keepQueryParams(true)
        ->schemes(['http'])
        ->host('legacy')
        ->options(['utf8' => true])
    ;
    $routes->add('url_redirect_route', '/redirect-url')
        ->redirectToUrl('/url-target')
        ->permanent(true)
        ->scheme('http')
        ->httpPort(1)
        ->httpsPort(2)
        ->keepRequestMethod(true)
        ->host('legacy')
        ->options(['utf8' => true])

@HeahDude HeahDude force-pushed the framework-routing branch 2 times, most recently from c67da45 to db3fdfd Compare December 10, 2019 21:34
@nicolas-grekas
Copy link
Member

Now that #34873 is merged, can you please rebase and take it into account to inject your new ContainerConfigurator?

@nicolas-grekas
Copy link
Member

Thank you @HeahDude.

nicolas-grekas added a commit that referenced this pull request Feb 9, 2020
…le template and redirect controllers (HeahDude)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[FrameworkBundle][Routing] added Configurators to handle template and redirect controllers

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | let's see
| Fixed tickets | partially #24640, #25145
| License       | MIT
| Doc PR        | symfony/symfony-docs#11120

While working on symfony/symfony-docs#11085, I felt bad about the long notations required for simple [redirects](https://symfony.com/doc/current/routing/redirect_in_config.html) and [templates rendering](https://symfony.com/doc/current/templating/render_without_controller.html) template actions, but I love and use those features since always. Then I gave it a try yesterday night and now I realised I missed #24640 and that #25145 has been closed x).

So here we go, here's my WIP. WDYT of this implementation? ping @javiereguiluz?

I'm going to open the PR in the docs so we can discuss the DX changes there too, and keep focus on the code here.

Cheers!

EDIT
----
This PR now only update PHP-DSL configurators.

______________

TODO:

- [x] gather reviews
- ~[x] fix xml schema~
- [x] add some tests
- ~[ ] handle xsd auto discovery~
- [x] rebase on top of #30507
- [x] ~add shortcuts for #30514~

Commits
-------

de74794 [FrameworkBundle][Routing] added Configurators to handle template and redirect controllers
@nicolas-grekas nicolas-grekas merged commit de74794 into symfony:master Feb 9, 2020
@HeahDude HeahDude deleted the framework-routing branch February 9, 2020 22:23
nicolas-grekas added a commit that referenced this pull request Feb 15, 2020
…ude)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[Routing] marked configurators traits as internal

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #30501 (comment) <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | not needed
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch master.
-->

Commits
-------

52efec7 [Routing] marked configurators traits as internal
nicolas-grekas added a commit to nicolas-grekas/symfony that referenced this pull request Apr 24, 2020
…urators to handle template and redirect controllers (HeahDude)"

This reverts commit 477ee19, reversing
changes made to 9bfa258.
nicolas-grekas added a commit to nicolas-grekas/symfony that referenced this pull request Apr 24, 2020
…urators to handle template and redirect controllers (HeahDude)"

This reverts commit 477ee19, reversing
changes made to 9bfa258.
fabpot added a commit that referenced this pull request Apr 24, 2020
…d Configurators to handle template and redirect controllers (HeahDude)" (nicolas-grekas)

This PR was merged into the 5.1-dev branch.

Discussion
----------

Revert "feature #30501 [FrameworkBundle][Routing] added Configurators to handle template and redirect controllers (HeahDude)"

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This reverts commit 477ee19, reversing changes made to 9bfa258.

The reverted PR is #30501. Actually, it's a partial revert: changes made to the `Routing` component are not reverted.

The reason for this revert is that a discussion is still on-going in #35653 (which provides the same configuration extensions to yaml+xml), and we won't be able to resolve them in time for 5.1.

Better postpone for 5.2.

@HeahDude I invite you to open a PR after this one, reverting this very PR, which we'll consider again but for 5.2 if you don't mind.

Commits
-------

e4e8945 Revert "feature #30501 [FrameworkBundle][Routing] added Configurators to handle template and redirect controllers (HeahDude)"
vjandrea pushed a commit to vjandrea/symfony that referenced this pull request Apr 25, 2020
…urators to handle template and redirect controllers (HeahDude)"

This reverts commit 477ee19, reversing
changes made to 9bfa258.
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
@fabpot fabpot mentioned this pull request May 5, 2020
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.

None yet

5 participants