-
Notifications
You must be signed in to change notification settings - Fork 71
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
Acrobat symfony5 support 2 #250
Conversation
@acrobat wdyt ? only problem i have is that i get mismatches on the |
@alexander-schranz can you try this branch in sulu and report if you run into any issues? are you using the bundle as well, or only the component? the bundle likely also needs some adjustments. |
@dbu Looks good! If you apply this diff, the expectedDeprecations work again (there was a Diff: https://gist.github.com/acrobat/c929ad46a84a91d1f51f18755e6dd85c |
@dbu looks good from the sulu side. Did not get any error and the routing did work. |
758474e
to
c969140
Compare
I think the travis build got "lost" during the maintenance this morning. Can you restart a new build in the travis interface? |
triggered a manual build: https://travis-ci.org/github/symfony-cmf/Routing/builds/677716799 (that will not update the PR here, but if its green, i guess i will merge) do you have any inputs on the code @acrobat or does it all look good? |
oh, actually travis-ci is very clever and did update us here. and even better, its green |
The code looks good to me! 🚢 |
Description ----------- This PR implements several long-discussed improvements we want to have in the Contao routing. ### Features: - [x] Configure URL-prefix (`.html`) per root page instead of the app config - [x] Configure the _prepend locale_ setting per root page instead of the app config - [x] Implement support for custom language prefix (closes #862) - [x] Only redirect to the language version of a page if it exists (see #1456) - [x] Generate routes for entities (e.g. pass `PageModel` to `$router->generate()` (see #831) - [x] Allow for custom page types as controllers (see #1160, #390) - [x] Allow a page type to have a static URL suffix (e.g. `.xml` instead of `.html` for the XML sitemap). #### Side Features - [ ] ~Do not generate frontend URLs for pages with parameters~ - [ ] ~add alternative to the `Input` class that also tracks unused parameters~ (not sure about this, as the Input is no longer used with routing parameters) - [x] _really_ only create template article for new pages that can have them - [x] do not create article if the new page's layout does not have articles ### Tasks - [ ] write documentation about _legacy routing mode_. - [ ] include support for extended languages (see https://github.com/contao/core-bundle/issues/1579) - [x] the url prefix should be unique for pages with the same dns setting. #1516 (comment) ### Follow-Up PRs - [x] Use router to generate SERP widget URL aschempp#3 - [ ] Replace current page types aschempp#4 - [ ] Support news aschempp#5 - [ ] Support calendar events aschempp#6 - [ ] Support other content (faq, etc.) ### Notes about backwards compatibility As discussed at the developer meeting in February 2020, we cannot keep full BC between the new features and the existing routing. The `contao.prepend_locale` and `contao.url_suffix` container configuration as well as the `getPageIdFromUrl` or `getRootPageFromUrl` hooks are conflicting with the new features. We agreed that Contao should fall into a _legacy routing_ mode, where the new features are not available in the root page in that case. **BC Todos:** - [x] Disable root page configuration in legacy routing mode - [x] ~Find a way to keep supporting `contao.routing.url_generator` service~ _only in legacy mode_ ### Related PRs / Dependencies: - [x] #1447 - [x] #1448 - [x] #1458 - [x] #1501 - [x] #1503 - [x] #1506 - [x] #1518 - [x] #1533 - [x] #1182 - [x] ~~#1639 - [x] #1640 - [x] #1650 - [x] #1652 - [x] #1864 - [x] #1869 - [x] #1896 Commits ------- 21a9efe Use page language instead of _locale parameter for $_GET['language'] c2ba2d1 Add languagePrefix and urlSuffix fields to tl_page d3abce3 Deprecate the bundle config but override the page config if set 78dfc42 Fix alias rendering in PageTree b8616b0 Rewrite the language filter to use the page properties ec3969d Add legacy routing check to ContaoFramework class 4f26e73 Added separate class to generate URL candidates 29bd111 Add languagePrefix and urlSuffix to PageModel with BC layer 510da35 Update RouteProvider to use candidates based on root page 02eca55 Add redirect routes if page is requested without languagePrefix 62f3656 Update routing functional tests c1f2f93 Added migration for tl_page fields 39d987b Set config values from current request 5b03a6c Correctly generate root and fallback routes with languagePrefix db9768f Check for ID/alias duplicate with new page parameters 83fc289 Use pageModel from request or trigger exception in deprecated methods without legacy mode 01b9c97 Update Route404Provider to use languagePrefix from PageModel 0d3f58b Fixed service arguments for LegacyRoutingListener bc02925 Added duplicates validation for alias, languagePrefix and urlSuffix 95c7042 Correctly migrate the legacy routing configuration 192fff1 CS and test fixes aa09e96 Switch page type and alias field position 11638ac Add route name and object to the attributes 139b19c Add custom route object for PageModel 223182e Content resolvers convert content to a route object 168c218 Let the page model tell if useAutoItem is enabled 8158ad2 Use service tagging to add router enhancers bda2a16 CS 44a5a43 Let the router generate page URLs b7bd00b Use the DynamicRouter from CMF Routing Bundle a8dcc22 Rename the ContentResolverInterface to ContentUrlResolverInterface 692742d Introducing page providers 190a38b Make PageRoute more flexible 5375860 Always render regular page for unknown types 4a27948 Added autoconfiguration for contao.page_provider 1b3bf76 Added RootPageProvider which provides the default url suffixes 0e559fc Generate page type options from providers c03f503 Added ContentCompositionListener to correctly show or hide article features 8b27f64 Added BC layer for UrlGenerator and other legacy routing 2c0115f Enable legacy routing by container configuration and throw exception if hooks require it a9f09bc Add legacy routing information to the data collector 156ef52 Trigger deprecation warnings if the Symfony routing is not used 928de08 Always show list of legacy routing hooks in profiler 079370f Rename languagePrefix to urlPrefix a015340 Include the previous exception on re-throw ca7ea33 Fix spelling in method name f384d55 Use ::class in exception message 1fc7bfd ContentUrlResolvers must always return a route f9cfbe8 Decorate the Candidates to implement legacy behavior dea83be Add an additional router for the legacy routes in legacy mode 41ab6c6 Adjust routing to string route name see symfony-cmf/Routing#250 1d7968c Fix remaining objects passed to Router::generate() 10b1b3e Add some deprecation notices and annotations 815e1c0 Fixed argument order in exception message 8fdbdf9 Use anonymous services for legacy routing ba67633 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Framework/ContaoFramework.php # core-bundle/src/Resources/config/services.yml # core-bundle/src/Resources/contao/dca/tl_article.php # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/src/Resources/contao/library/Contao/Template.php # core-bundle/src/Resources/contao/themes/flexible/main.min.css # core-bundle/tests/Routing/Enhancer/InputEnhancerTest.php # core-bundle/tests/Routing/Route404ProviderTest.php 50ba4cd Fix incorrect service name fc680b7 Fix unit tests for ContaoCoreExtension 534ccdd Fix some tests e0118c4 The contao.routing.url_generator is only available in legacy mode f6f1d19 Fix remaining unit tests 87c121a CS f7ae7a9 Trigger route error only when used 6ba5f7a Added 100% test coverage for ContentCompositionListener 74f8c7c Added missing unit tests 22394dd Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/tests/DependencyInjection/ContaoCoreExtensionTest.php # core-bundle/tests/Functional/RoutingTest.php 325b114 Fixed ContaoCoreExtensionTest 5627ec3 CS 888ec70 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/tests/Asset/ContaoContextTest.php 701cd59 CS 0be7232 Always insert the new article into an available layout column cbd42ac Expect deprecations afc706a CS 577f1fa CS c719b1c CS e51d432 Move classes to new namespace 5b30edd Refactor with PageRouteFactory edd253e Added PageRegistry de480f2 CS and tests 629300e Added concept of path parameters bb76ae6 Fixed service name 793b3d5 Providing URL suffixes without custom routes does not make sense 4692bcc PageModel is not optional 502276a Make the RouteFactory more generic f11ab17 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Framework/ContaoFramework.php 4dd724a Tests 6288646 Fixed failing test if there are no url suffixes ae90ba6 Logger is optional d696ed9 Logger is optional 0262068 phpstan 613c39e phpstan 2afd655 phpstan & tests 37c4dda phpstan & tests c337e1b phpstan & tests 5b78fa6 Merge remote-tracking branch 'upstream/master' into feature/routing 8342fa0 psalm & tests edb1e52 yamllint 194f942 Do not use warning color if legacy routing is disabled 5a1b41a Reuse class name variable c422a02 Register interfaces for autoconfiguration c93b1e6 Drop unnecessary tags with autoconfigure 4328f77 Correctly purge search index b5d4be1 Use PathUtil to check if hook is in vendor dir ece1376 Throw correct exception if route is not supported c60854c Merge remote-tracking branch 'upstream/master' into feature/routing f4ca10f Use the security voter to check article permissions 61bccf7 Tests 04f50f1 Tests c4b004b Rename page controllers a806b39 Use subscribed services 289cc0b URL must include prefix and suffix when generating candidates 2e507a4 CS a63f337 Rewrite candidates d023ee3 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Resources/contao/library/Contao/Controller.php e46b79a Fixed return type 82fbcc4 Code review 491c83b Code review 681dafd Check if the URL prefix is duplicated in another root page 2fa6eee Merge remote-tracking branch 'upstream/master' into feature/routing bfab096 Fix the coding style c1cca71 Merge branch 'master' into feature/routing f3cbd68 Fix the unit tests 63188d6 Fix the phpDoc types 92ea072 Adjust the deprecation messages 35e4d71 Fix a non-optimal if condition 7ba51e7 Fix some minor issues fba7c23 Adjust the "this setting has been disabled" warning a1d0532 Review from @dmolineus a972f8d Review from @leofeyer 164291b Fixed Route404Provider tests 0dea19a Use permission constants 5c72385 Remove invalid model methods 444c736 Use callback instead of listener method for help icon 6ef2654 Fix the coding style d9a259a Fix a wrong trans-unit ID 351c32f Replace "@var Adapter" with something the IDE and PhpStan understand ab6cb7e Correctly generate the index route b01b059 Correctly match a request with url prefix if there is no index page c089b6d Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/ContaoCoreBundle.php # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/src/Resources/contao/models/PageModel.php # core-bundle/src/Routing/RouteProvider.php # core-bundle/tests/ContaoCoreBundleTest.php c338e4a CS 7763b81 Fix the CI chain 5db0afe Drop the parameters field a4aba62 Allow to define content composition in the service tag/annotation 31d34ec Get URL prefix and suffix from the page registry ea8f57b Rename the PageRouteEnhancerInterface 2e373e4 Update RootController, no longer needs additional interfaces b895744 Allow relative or absolute path for page controllers 3295ed8 CS 524c5e6 Fix tests 5850c24 CS 961ffcd Use $this->createResult() instead of new MigrationResult() 1f70bdb Implemented feedback from @Toflar ded7d5c Correctly validate the URL suffix 64b388e Correctly support absolute URLs with empty prefix f7fda16 CS
Description ----------- This PR implements several long-discussed improvements we want to have in the Contao routing. ### Features: - [x] Configure URL-prefix (`.html`) per root page instead of the app config - [x] Configure the _prepend locale_ setting per root page instead of the app config - [x] Implement support for custom language prefix (closes contao/contao#862) - [x] Only redirect to the language version of a page if it exists (see contao/contao#1456) - [x] Generate routes for entities (e.g. pass `PageModel` to `$router->generate()` (see contao/contao#831) - [x] Allow for custom page types as controllers (see contao/contao#1160, contao/contao#390) - [x] Allow a page type to have a static URL suffix (e.g. `.xml` instead of `.html` for the XML sitemap). #### Side Features - [ ] ~Do not generate frontend URLs for pages with parameters~ - [ ] ~add alternative to the `Input` class that also tracks unused parameters~ (not sure about this, as the Input is no longer used with routing parameters) - [x] _really_ only create template article for new pages that can have them - [x] do not create article if the new page's layout does not have articles ### Tasks - [ ] write documentation about _legacy routing mode_. - [ ] include support for extended languages (see https://github.com/contao/core-bundle/issues/1579) - [x] the url prefix should be unique for pages with the same dns setting. contao/contao#1516 (comment) ### Follow-Up PRs - [x] Use router to generate SERP widget URL aschempp/contao#3 - [ ] Replace current page types aschempp/contao#4 - [ ] Support news aschempp/contao#5 - [ ] Support calendar events aschempp/contao#6 - [ ] Support other content (faq, etc.) ### Notes about backwards compatibility As discussed at the developer meeting in February 2020, we cannot keep full BC between the new features and the existing routing. The `contao.prepend_locale` and `contao.url_suffix` container configuration as well as the `getPageIdFromUrl` or `getRootPageFromUrl` hooks are conflicting with the new features. We agreed that Contao should fall into a _legacy routing_ mode, where the new features are not available in the root page in that case. **BC Todos:** - [x] Disable root page configuration in legacy routing mode - [x] ~Find a way to keep supporting `contao.routing.url_generator` service~ _only in legacy mode_ ### Related PRs / Dependencies: - [x] contao/contao#1447 - [x] contao/contao#1448 - [x] contao/contao#1458 - [x] contao/contao#1501 - [x] contao/contao#1503 - [x] contao/contao#1506 - [x] #1518 - [x] #1533 - [x] #1182 - [x] ~~contao/contao#1639 - [x] contao/contao#1640 - [x] contao/contao#1650 - [x] contao/contao#1652 - [x] contao/contao#1864 - [x] contao/contao#1869 - [x] contao/contao#1896 Commits ------- 21a9efee Use page language instead of _locale parameter for $_GET['language'] c2ba2d18 Add languagePrefix and urlSuffix fields to tl_page d3abce32 Deprecate the bundle config but override the page config if set 78dfc423 Fix alias rendering in PageTree b8616b07 Rewrite the language filter to use the page properties ec3969d4 Add legacy routing check to ContaoFramework class 4f26e730 Added separate class to generate URL candidates 29bd1112 Add languagePrefix and urlSuffix to PageModel with BC layer 510da353 Update RouteProvider to use candidates based on root page 02eca555 Add redirect routes if page is requested without languagePrefix 62f36562 Update routing functional tests c1f2f93b Added migration for tl_page fields 39d987b6 Set config values from current request 5b03a6cf Correctly generate root and fallback routes with languagePrefix db9768f4 Check for ID/alias duplicate with new page parameters 83fc2890 Use pageModel from request or trigger exception in deprecated methods without legacy mode 01b9c97b Update Route404Provider to use languagePrefix from PageModel 0d3f58bf Fixed service arguments for LegacyRoutingListener bc029251 Added duplicates validation for alias, languagePrefix and urlSuffix 95c7042a Correctly migrate the legacy routing configuration 192fff16 CS and test fixes aa09e969 Switch page type and alias field position 11638acb Add route name and object to the attributes 139b19c3 Add custom route object for PageModel 223182e2 Content resolvers convert content to a route object 168c2182 Let the page model tell if useAutoItem is enabled 8158ad24 Use service tagging to add router enhancers bda2a160 CS 44a5a433 Let the router generate page URLs b7bd00bc Use the DynamicRouter from CMF Routing Bundle a8dcc223 Rename the ContentResolverInterface to ContentUrlResolverInterface 692742d8 Introducing page providers 190a38b1 Make PageRoute more flexible 53758600 Always render regular page for unknown types 4a27948d Added autoconfiguration for contao.page_provider 1b3bf760 Added RootPageProvider which provides the default url suffixes 0e559fc9 Generate page type options from providers c03f5037 Added ContentCompositionListener to correctly show or hide article features 8b27f64d Added BC layer for UrlGenerator and other legacy routing 2c0115f0 Enable legacy routing by container configuration and throw exception if hooks require it a9f09bca Add legacy routing information to the data collector 156ef523 Trigger deprecation warnings if the Symfony routing is not used 928de089 Always show list of legacy routing hooks in profiler 079370f9 Rename languagePrefix to urlPrefix a0153401 Include the previous exception on re-throw ca7ea33d Fix spelling in method name f384d55c Use ::class in exception message 1fc7bfd6 ContentUrlResolvers must always return a route f9cfbe88 Decorate the Candidates to implement legacy behavior dea83bef Add an additional router for the legacy routes in legacy mode 41ab6c65 Adjust routing to string route name see symfony-cmf/Routing#250 1d7968c1 Fix remaining objects passed to Router::generate() 10b1b3e3 Add some deprecation notices and annotations 815e1c07 Fixed argument order in exception message 8fdbdf95 Use anonymous services for legacy routing ba676339 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Framework/ContaoFramework.php # core-bundle/src/Resources/config/services.yml # core-bundle/src/Resources/contao/dca/tl_article.php # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/src/Resources/contao/library/Contao/Template.php # core-bundle/src/Resources/contao/themes/flexible/main.min.css # core-bundle/tests/Routing/Enhancer/InputEnhancerTest.php # core-bundle/tests/Routing/Route404ProviderTest.php 50ba4cd8 Fix incorrect service name fc680b74 Fix unit tests for ContaoCoreExtension 534ccdd9 Fix some tests e0118c44 The contao.routing.url_generator is only available in legacy mode f6f1d198 Fix remaining unit tests 87c121ac CS f7ae7a9e Trigger route error only when used 6ba5f7a1 Added 100% test coverage for ContentCompositionListener 74f8c7c5 Added missing unit tests 22394dda Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/tests/DependencyInjection/ContaoCoreExtensionTest.php # core-bundle/tests/Functional/RoutingTest.php 325b1147 Fixed ContaoCoreExtensionTest 5627ec33 CS 888ec702 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/tests/Asset/ContaoContextTest.php 701cd593 CS 0be72326 Always insert the new article into an available layout column cbd42acc Expect deprecations afc706a1 CS 577f1fa3 CS c719b1c5 CS e51d4324 Move classes to new namespace 5b30edde Refactor with PageRouteFactory edd253ef Added PageRegistry de480f2f CS and tests 629300e4 Added concept of path parameters bb76ae64 Fixed service name 793b3d56 Providing URL suffixes without custom routes does not make sense 4692bccd PageModel is not optional 502276ad Make the RouteFactory more generic f11ab176 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Framework/ContaoFramework.php 4dd724af Tests 62886460 Fixed failing test if there are no url suffixes ae90ba66 Logger is optional d696ed9d Logger is optional 0262068f phpstan 613c39ee phpstan 2afd655c phpstan & tests 37c4dda4 phpstan & tests c337e1b0 phpstan & tests 5b78fa64 Merge remote-tracking branch 'upstream/master' into feature/routing 8342fa0b psalm & tests edb1e52b yamllint 194f942a Do not use warning color if legacy routing is disabled 5a1b41a1 Reuse class name variable c422a021 Register interfaces for autoconfiguration c93b1e6d Drop unnecessary tags with autoconfigure 4328f77a Correctly purge search index b5d4be1e Use PathUtil to check if hook is in vendor dir ece1376c Throw correct exception if route is not supported c60854cb Merge remote-tracking branch 'upstream/master' into feature/routing f4ca10f7 Use the security voter to check article permissions 61bccf79 Tests 04f50f1e Tests c4b004bb Rename page controllers a806b39c Use subscribed services 289cc0ba URL must include prefix and suffix when generating candidates 2e507a45 CS a63f3373 Rewrite candidates d023ee3e Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Resources/contao/library/Contao/Controller.php e46b79ad Fixed return type 82fbcc41 Code review 491c83b9 Code review 681dafdc Check if the URL prefix is duplicated in another root page 2fa6eee0 Merge remote-tracking branch 'upstream/master' into feature/routing bfab096b Fix the coding style c1cca71f Merge branch 'master' into feature/routing f3cbd681 Fix the unit tests 63188d64 Fix the phpDoc types 92ea0725 Adjust the deprecation messages 35e4d71e Fix a non-optimal if condition 7ba51e75 Fix some minor issues fba7c23a Adjust the "this setting has been disabled" warning a1d05327 Review from @dmolineus a972f8d8 Review from @leofeyer 164291bb Fixed Route404Provider tests 0dea19a8 Use permission constants 5c723859 Remove invalid model methods 444c7364 Use callback instead of listener method for help icon 6ef2654c Fix the coding style d9a259ae Fix a wrong trans-unit ID 351c32fa Replace "@var Adapter" with something the IDE and PhpStan understand ab6cb7eb Correctly generate the index route b01b0598 Correctly match a request with url prefix if there is no index page c089b6dd Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/ContaoCoreBundle.php # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/src/Resources/contao/models/PageModel.php # core-bundle/src/Routing/RouteProvider.php # core-bundle/tests/ContaoCoreBundleTest.php c338e4a0 CS 7763b81d Fix the CI chain 5db0afe7 Drop the parameters field a4aba627 Allow to define content composition in the service tag/annotation 31d34ec2 Get URL prefix and suffix from the page registry ea8f57bd Rename the PageRouteEnhancerInterface 2e373e43 Update RootController, no longer needs additional interfaces b8957447 Allow relative or absolute path for page controllers 3295ed80 CS 524c5e62 Fix tests 5850c246 CS 961ffcd4 Use $this->createResult() instead of new MigrationResult() 1f70bdbe Implemented feedback from @Toflar ded7d5c2 Correctly validate the URL suffix 64b388e0 Correctly support absolute URLs with empty prefix f7fda160 CS
Description ----------- This PR implements several long-discussed improvements we want to have in the Contao routing. ### Features: - [x] Configure URL-prefix (`.html`) per root page instead of the app config - [x] Configure the _prepend locale_ setting per root page instead of the app config - [x] Implement support for custom language prefix (closes contao/contao#862) - [x] Only redirect to the language version of a page if it exists (see contao/contao#1456) - [x] Generate routes for entities (e.g. pass `PageModel` to `$router->generate()` (see contao/contao#831) - [x] Allow for custom page types as controllers (see contao/contao#1160, contao/contao#390) - [x] Allow a page type to have a static URL suffix (e.g. `.xml` instead of `.html` for the XML sitemap). #### Side Features - [ ] ~Do not generate frontend URLs for pages with parameters~ - [ ] ~add alternative to the `Input` class that also tracks unused parameters~ (not sure about this, as the Input is no longer used with routing parameters) - [x] _really_ only create template article for new pages that can have them - [x] do not create article if the new page's layout does not have articles ### Tasks - [ ] write documentation about _legacy routing mode_. - [ ] include support for extended languages (see https://github.com/contao/core-bundle/issues/1579) - [x] the url prefix should be unique for pages with the same dns setting. contao/contao#1516 (comment) ### Follow-Up PRs - [x] Use router to generate SERP widget URL aschempp/contao#3 - [ ] Replace current page types aschempp/contao#4 - [ ] Support news aschempp/contao#5 - [ ] Support calendar events aschempp/contao#6 - [ ] Support other content (faq, etc.) ### Notes about backwards compatibility As discussed at the developer meeting in February 2020, we cannot keep full BC between the new features and the existing routing. The `contao.prepend_locale` and `contao.url_suffix` container configuration as well as the `getPageIdFromUrl` or `getRootPageFromUrl` hooks are conflicting with the new features. We agreed that Contao should fall into a _legacy routing_ mode, where the new features are not available in the root page in that case. **BC Todos:** - [x] Disable root page configuration in legacy routing mode - [x] ~Find a way to keep supporting `contao.routing.url_generator` service~ _only in legacy mode_ ### Related PRs / Dependencies: - [x] contao/contao#1447 - [x] contao/contao#1448 - [x] contao/contao#1458 - [x] contao/contao#1501 - [x] contao/contao#1503 - [x] contao/contao#1506 - [x] #1518 - [x] #1533 - [x] #1182 - [x] ~~contao/contao#1639 - [x] contao/contao#1640 - [x] contao/contao#1650 - [x] contao/contao#1652 - [x] contao/contao#1864 - [x] contao/contao#1869 - [x] contao/contao#1896 Commits ------- 21a9efee Use page language instead of _locale parameter for $_GET['language'] c2ba2d18 Add languagePrefix and urlSuffix fields to tl_page d3abce32 Deprecate the bundle config but override the page config if set 78dfc423 Fix alias rendering in PageTree b8616b07 Rewrite the language filter to use the page properties ec3969d4 Add legacy routing check to ContaoFramework class 4f26e730 Added separate class to generate URL candidates 29bd1112 Add languagePrefix and urlSuffix to PageModel with BC layer 510da353 Update RouteProvider to use candidates based on root page 02eca555 Add redirect routes if page is requested without languagePrefix 62f36562 Update routing functional tests c1f2f93b Added migration for tl_page fields 39d987b6 Set config values from current request 5b03a6cf Correctly generate root and fallback routes with languagePrefix db9768f4 Check for ID/alias duplicate with new page parameters 83fc2890 Use pageModel from request or trigger exception in deprecated methods without legacy mode 01b9c97b Update Route404Provider to use languagePrefix from PageModel 0d3f58bf Fixed service arguments for LegacyRoutingListener bc029251 Added duplicates validation for alias, languagePrefix and urlSuffix 95c7042a Correctly migrate the legacy routing configuration 192fff16 CS and test fixes aa09e969 Switch page type and alias field position 11638acb Add route name and object to the attributes 139b19c3 Add custom route object for PageModel 223182e2 Content resolvers convert content to a route object 168c2182 Let the page model tell if useAutoItem is enabled 8158ad24 Use service tagging to add router enhancers bda2a160 CS 44a5a433 Let the router generate page URLs b7bd00bc Use the DynamicRouter from CMF Routing Bundle a8dcc223 Rename the ContentResolverInterface to ContentUrlResolverInterface 692742d8 Introducing page providers 190a38b1 Make PageRoute more flexible 53758600 Always render regular page for unknown types 4a27948d Added autoconfiguration for contao.page_provider 1b3bf760 Added RootPageProvider which provides the default url suffixes 0e559fc9 Generate page type options from providers c03f5037 Added ContentCompositionListener to correctly show or hide article features 8b27f64d Added BC layer for UrlGenerator and other legacy routing 2c0115f0 Enable legacy routing by container configuration and throw exception if hooks require it a9f09bca Add legacy routing information to the data collector 156ef523 Trigger deprecation warnings if the Symfony routing is not used 928de089 Always show list of legacy routing hooks in profiler 079370f9 Rename languagePrefix to urlPrefix a0153401 Include the previous exception on re-throw ca7ea33d Fix spelling in method name f384d55c Use ::class in exception message 1fc7bfd6 ContentUrlResolvers must always return a route f9cfbe88 Decorate the Candidates to implement legacy behavior dea83bef Add an additional router for the legacy routes in legacy mode 41ab6c65 Adjust routing to string route name see symfony-cmf/Routing#250 1d7968c1 Fix remaining objects passed to Router::generate() 10b1b3e3 Add some deprecation notices and annotations 815e1c07 Fixed argument order in exception message 8fdbdf95 Use anonymous services for legacy routing ba676339 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Framework/ContaoFramework.php # core-bundle/src/Resources/config/services.yml # core-bundle/src/Resources/contao/dca/tl_article.php # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/src/Resources/contao/library/Contao/Template.php # core-bundle/src/Resources/contao/themes/flexible/main.min.css # core-bundle/tests/Routing/Enhancer/InputEnhancerTest.php # core-bundle/tests/Routing/Route404ProviderTest.php 50ba4cd8 Fix incorrect service name fc680b74 Fix unit tests for ContaoCoreExtension 534ccdd9 Fix some tests e0118c44 The contao.routing.url_generator is only available in legacy mode f6f1d198 Fix remaining unit tests 87c121ac CS f7ae7a9e Trigger route error only when used 6ba5f7a1 Added 100% test coverage for ContentCompositionListener 74f8c7c5 Added missing unit tests 22394dda Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/tests/DependencyInjection/ContaoCoreExtensionTest.php # core-bundle/tests/Functional/RoutingTest.php 325b1147 Fixed ContaoCoreExtensionTest 5627ec33 CS 888ec702 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/tests/Asset/ContaoContextTest.php 701cd593 CS 0be72326 Always insert the new article into an available layout column cbd42acc Expect deprecations afc706a1 CS 577f1fa3 CS c719b1c5 CS e51d4324 Move classes to new namespace 5b30edde Refactor with PageRouteFactory edd253ef Added PageRegistry de480f2f CS and tests 629300e4 Added concept of path parameters bb76ae64 Fixed service name 793b3d56 Providing URL suffixes without custom routes does not make sense 4692bccd PageModel is not optional 502276ad Make the RouteFactory more generic f11ab176 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Framework/ContaoFramework.php 4dd724af Tests 62886460 Fixed failing test if there are no url suffixes ae90ba66 Logger is optional d696ed9d Logger is optional 0262068f phpstan 613c39ee phpstan 2afd655c phpstan & tests 37c4dda4 phpstan & tests c337e1b0 phpstan & tests 5b78fa64 Merge remote-tracking branch 'upstream/master' into feature/routing 8342fa0b psalm & tests edb1e52b yamllint 194f942a Do not use warning color if legacy routing is disabled 5a1b41a1 Reuse class name variable c422a021 Register interfaces for autoconfiguration c93b1e6d Drop unnecessary tags with autoconfigure 4328f77a Correctly purge search index b5d4be1e Use PathUtil to check if hook is in vendor dir ece1376c Throw correct exception if route is not supported c60854cb Merge remote-tracking branch 'upstream/master' into feature/routing f4ca10f7 Use the security voter to check article permissions 61bccf79 Tests 04f50f1e Tests c4b004bb Rename page controllers a806b39c Use subscribed services 289cc0ba URL must include prefix and suffix when generating candidates 2e507a45 CS a63f3373 Rewrite candidates d023ee3e Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Resources/contao/library/Contao/Controller.php e46b79ad Fixed return type 82fbcc41 Code review 491c83b9 Code review 681dafdc Check if the URL prefix is duplicated in another root page 2fa6eee0 Merge remote-tracking branch 'upstream/master' into feature/routing bfab096b Fix the coding style c1cca71f Merge branch 'master' into feature/routing f3cbd681 Fix the unit tests 63188d64 Fix the phpDoc types 92ea0725 Adjust the deprecation messages 35e4d71e Fix a non-optimal if condition 7ba51e75 Fix some minor issues fba7c23a Adjust the "this setting has been disabled" warning a1d05327 Review from @dmolineus a972f8d8 Review from @leofeyer 164291bb Fixed Route404Provider tests 0dea19a8 Use permission constants 5c723859 Remove invalid model methods 444c7364 Use callback instead of listener method for help icon 6ef2654c Fix the coding style d9a259ae Fix a wrong trans-unit ID 351c32fa Replace "@var Adapter" with something the IDE and PhpStan understand ab6cb7eb Correctly generate the index route b01b0598 Correctly match a request with url prefix if there is no index page c089b6dd Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/ContaoCoreBundle.php # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/src/Resources/contao/models/PageModel.php # core-bundle/src/Routing/RouteProvider.php # core-bundle/tests/ContaoCoreBundleTest.php c338e4a0 CS 7763b81d Fix the CI chain 5db0afe7 Drop the parameters field a4aba627 Allow to define content composition in the service tag/annotation 31d34ec2 Get URL prefix and suffix from the page registry ea8f57bd Rename the PageRouteEnhancerInterface 2e373e43 Update RootController, no longer needs additional interfaces b8957447 Allow relative or absolute path for page controllers 3295ed80 CS 524c5e62 Fix tests 5850c246 CS 961ffcd4 Use $this->createResult() instead of new MigrationResult() 1f70bdbe Implemented feedback from @Toflar ded7d5c2 Correctly validate the URL suffix 64b388e0 Correctly support absolute URLs with empty prefix f7fda160 CS
Description ----------- This PR implements several long-discussed improvements we want to have in the Contao routing. ### Features: - [x] Configure URL-prefix (`.html`) per root page instead of the app config - [x] Configure the _prepend locale_ setting per root page instead of the app config - [x] Implement support for custom language prefix (closes contao#862) - [x] Only redirect to the language version of a page if it exists (see contao#1456) - [x] Generate routes for entities (e.g. pass `PageModel` to `$router->generate()` (see contao#831) - [x] Allow for custom page types as controllers (see contao#1160, contao#390) - [x] Allow a page type to have a static URL suffix (e.g. `.xml` instead of `.html` for the XML sitemap). #### Side Features - [ ] ~Do not generate frontend URLs for pages with parameters~ - [ ] ~add alternative to the `Input` class that also tracks unused parameters~ (not sure about this, as the Input is no longer used with routing parameters) - [x] _really_ only create template article for new pages that can have them - [x] do not create article if the new page's layout does not have articles ### Tasks - [ ] write documentation about _legacy routing mode_. - [ ] include support for extended languages (see https://github.com/contao/core-bundle/issues/1579) - [x] the url prefix should be unique for pages with the same dns setting. contao#1516 (comment) ### Follow-Up PRs - [x] Use router to generate SERP widget URL aschempp#3 - [ ] Replace current page types aschempp#4 - [ ] Support news aschempp#5 - [ ] Support calendar events aschempp#6 - [ ] Support other content (faq, etc.) ### Notes about backwards compatibility As discussed at the developer meeting in February 2020, we cannot keep full BC between the new features and the existing routing. The `contao.prepend_locale` and `contao.url_suffix` container configuration as well as the `getPageIdFromUrl` or `getRootPageFromUrl` hooks are conflicting with the new features. We agreed that Contao should fall into a _legacy routing_ mode, where the new features are not available in the root page in that case. **BC Todos:** - [x] Disable root page configuration in legacy routing mode - [x] ~Find a way to keep supporting `contao.routing.url_generator` service~ _only in legacy mode_ ### Related PRs / Dependencies: - [x] contao#1447 - [x] contao#1448 - [x] contao#1458 - [x] contao#1501 - [x] contao#1503 - [x] contao#1506 - [x] contao#1518 - [x] contao#1533 - [x] contao#1182 - [x] ~~contao#1639 - [x] contao#1640 - [x] contao#1650 - [x] contao#1652 - [x] contao#1864 - [x] contao#1869 - [x] contao#1896 Commits ------- 21a9efe Use page language instead of _locale parameter for $_GET['language'] c2ba2d1 Add languagePrefix and urlSuffix fields to tl_page d3abce3 Deprecate the bundle config but override the page config if set 78dfc42 Fix alias rendering in PageTree b8616b0 Rewrite the language filter to use the page properties ec3969d Add legacy routing check to ContaoFramework class 4f26e73 Added separate class to generate URL candidates 29bd111 Add languagePrefix and urlSuffix to PageModel with BC layer 510da35 Update RouteProvider to use candidates based on root page 02eca55 Add redirect routes if page is requested without languagePrefix 62f3656 Update routing functional tests c1f2f93 Added migration for tl_page fields 39d987b Set config values from current request 5b03a6c Correctly generate root and fallback routes with languagePrefix db9768f Check for ID/alias duplicate with new page parameters 83fc289 Use pageModel from request or trigger exception in deprecated methods without legacy mode 01b9c97 Update Route404Provider to use languagePrefix from PageModel 0d3f58b Fixed service arguments for LegacyRoutingListener bc02925 Added duplicates validation for alias, languagePrefix and urlSuffix 95c7042 Correctly migrate the legacy routing configuration 192fff1 CS and test fixes aa09e96 Switch page type and alias field position 11638ac Add route name and object to the attributes 139b19c Add custom route object for PageModel 223182e Content resolvers convert content to a route object 168c218 Let the page model tell if useAutoItem is enabled 8158ad2 Use service tagging to add router enhancers bda2a16 CS 44a5a43 Let the router generate page URLs b7bd00b Use the DynamicRouter from CMF Routing Bundle a8dcc22 Rename the ContentResolverInterface to ContentUrlResolverInterface 692742d Introducing page providers 190a38b Make PageRoute more flexible 5375860 Always render regular page for unknown types 4a27948 Added autoconfiguration for contao.page_provider 1b3bf76 Added RootPageProvider which provides the default url suffixes 0e559fc Generate page type options from providers c03f503 Added ContentCompositionListener to correctly show or hide article features 8b27f64 Added BC layer for UrlGenerator and other legacy routing 2c0115f Enable legacy routing by container configuration and throw exception if hooks require it a9f09bc Add legacy routing information to the data collector 156ef52 Trigger deprecation warnings if the Symfony routing is not used 928de08 Always show list of legacy routing hooks in profiler 079370f Rename languagePrefix to urlPrefix a015340 Include the previous exception on re-throw ca7ea33 Fix spelling in method name f384d55 Use ::class in exception message 1fc7bfd ContentUrlResolvers must always return a route f9cfbe8 Decorate the Candidates to implement legacy behavior dea83be Add an additional router for the legacy routes in legacy mode 41ab6c6 Adjust routing to string route name see symfony-cmf/Routing#250 1d7968c Fix remaining objects passed to Router::generate() 10b1b3e Add some deprecation notices and annotations 815e1c0 Fixed argument order in exception message 8fdbdf9 Use anonymous services for legacy routing ba67633 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Framework/ContaoFramework.php # core-bundle/src/Resources/config/services.yml # core-bundle/src/Resources/contao/dca/tl_article.php # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/src/Resources/contao/library/Contao/Template.php # core-bundle/src/Resources/contao/themes/flexible/main.min.css # core-bundle/tests/Routing/Enhancer/InputEnhancerTest.php # core-bundle/tests/Routing/Route404ProviderTest.php 50ba4cd Fix incorrect service name fc680b7 Fix unit tests for ContaoCoreExtension 534ccdd Fix some tests e0118c4 The contao.routing.url_generator is only available in legacy mode f6f1d19 Fix remaining unit tests 87c121a CS f7ae7a9 Trigger route error only when used 6ba5f7a Added 100% test coverage for ContentCompositionListener 74f8c7c Added missing unit tests 22394dd Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/tests/DependencyInjection/ContaoCoreExtensionTest.php # core-bundle/tests/Functional/RoutingTest.php 325b114 Fixed ContaoCoreExtensionTest 5627ec3 CS 888ec70 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/tests/Asset/ContaoContextTest.php 701cd59 CS 0be7232 Always insert the new article into an available layout column cbd42ac Expect deprecations afc706a CS 577f1fa CS c719b1c CS e51d432 Move classes to new namespace 5b30edd Refactor with PageRouteFactory edd253e Added PageRegistry de480f2 CS and tests 629300e Added concept of path parameters bb76ae6 Fixed service name 793b3d5 Providing URL suffixes without custom routes does not make sense 4692bcc PageModel is not optional 502276a Make the RouteFactory more generic f11ab17 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Framework/ContaoFramework.php 4dd724a Tests 6288646 Fixed failing test if there are no url suffixes ae90ba6 Logger is optional d696ed9 Logger is optional 0262068 phpstan 613c39e phpstan 2afd655 phpstan & tests 37c4dda phpstan & tests c337e1b phpstan & tests 5b78fa6 Merge remote-tracking branch 'upstream/master' into feature/routing 8342fa0 psalm & tests edb1e52 yamllint 194f942 Do not use warning color if legacy routing is disabled 5a1b41a Reuse class name variable c422a02 Register interfaces for autoconfiguration c93b1e6 Drop unnecessary tags with autoconfigure 4328f77 Correctly purge search index b5d4be1 Use PathUtil to check if hook is in vendor dir ece1376 Throw correct exception if route is not supported c60854c Merge remote-tracking branch 'upstream/master' into feature/routing f4ca10f Use the security voter to check article permissions 61bccf7 Tests 04f50f1 Tests c4b004b Rename page controllers a806b39 Use subscribed services 289cc0b URL must include prefix and suffix when generating candidates 2e507a4 CS a63f337 Rewrite candidates d023ee3 Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/Resources/contao/library/Contao/Controller.php e46b79a Fixed return type 82fbcc4 Code review 491c83b Code review 681dafd Check if the URL prefix is duplicated in another root page 2fa6eee Merge remote-tracking branch 'upstream/master' into feature/routing bfab096 Fix the coding style c1cca71 Merge branch 'master' into feature/routing f3cbd68 Fix the unit tests 63188d6 Fix the phpDoc types 92ea072 Adjust the deprecation messages 35e4d71 Fix a non-optimal if condition 7ba51e7 Fix some minor issues fba7c23 Adjust the "this setting has been disabled" warning a1d0532 Review from @dmolineus a972f8d Review from @leofeyer 164291b Fixed Route404Provider tests 0dea19a Use permission constants 5c72385 Remove invalid model methods 444c736 Use callback instead of listener method for help icon 6ef2654 Fix the coding style d9a259a Fix a wrong trans-unit ID 351c32f Replace "@var Adapter" with something the IDE and PhpStan understand ab6cb7e Correctly generate the index route b01b059 Correctly match a request with url prefix if there is no index page c089b6d Merge remote-tracking branch 'upstream/master' into feature/routing # Conflicts: # core-bundle/src/ContaoCoreBundle.php # core-bundle/src/Resources/contao/dca/tl_page.php # core-bundle/src/Resources/contao/models/PageModel.php # core-bundle/src/Routing/RouteProvider.php # core-bundle/tests/ContaoCoreBundleTest.php c338e4a CS 7763b81 Fix the CI chain 5db0afe Drop the parameters field a4aba62 Allow to define content composition in the service tag/annotation 31d34ec Get URL prefix and suffix from the page registry ea8f57b Rename the PageRouteEnhancerInterface 2e373e4 Update RootController, no longer needs additional interfaces b895744 Allow relative or absolute path for page controllers 3295ed8 CS 524c5e6 Fix tests 5850c24 CS 961ffcd Use $this->createResult() instead of new MigrationResult() 1f70bdb Implemented feedback from @Toflar ded7d5c Correctly validate the URL suffix 64b388e Correctly support absolute URLs with empty prefix f7fda16 CS
Continuation of the work by @acrobat
I realized that the VersatileRouterInterface is used to provide meaningful debug messages when something did not work, and i think for that its worth to keep it. So i only deprecated the
supports
method. And adjusted the debug message method to handle the new mode as well.