Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[FrameworkBundle][Routing] added proper Loader namespace to handle controllers #30501
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.
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.
Apart this last points, the feature is ready from side, only reviews needed now :), thanks!
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
… "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
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.
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])