Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
\Drupal\Core\Routing\Router::generate()
is deprecated by we want people to use \Drupal\Core\Url object instead but this method is on aSymfony interface so we can't get rid of it.
This deprecation was added in #2810303: Reunite the router: One router to rule them all
Proposed resolution
Change to a warning? Exception?
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#6 | 3114869-6.patch | 2.33 KB | andypost |
#4 | 3114869.patch | 769 bytes | Gábor Hojtsy |
Comments
Comment #2
catchI think we would want to end up with an exception, but if we do that, should we redeprecate for Drupal 10? We'd need to update the message too to say it'll throw an exception as opposed to being removed.
Comment #3
andypostAlso there's 4 other implementations of interface except
\Drupal\Core\Routing\Router::generate()
-
\Drupal\Core\Routing\AccessAwareRouter::generate()
-
\Drupal\Core\Routing\UrlGenerator::generate()
-
\Drupal\Core\Render\MetadataBubblingUrlGenerator::generate()
- testing code
\Drupal\help_test\SupernovaGenerator::generate()
(throws exception)Comment #4
Gábor HojtsyIn discussion @catch proposed this:
We cannot remove this as it is part of a Symfony interface. That said, it is not entirely fulfilling the interface contract if we are throwing an exception form it either, but that we can resolve in Drupal 9 to 10.
It was introduced deprecated outright in #2810303: Reunite the router: One router to rule them all before 8.3.0, that much I digged up. I don't think that is a good URL to include in the trigger_error() so I did not add that.
How does this look like?
Comment #5
andypostIt could use
__METHOD__
instead of__NAMESPACE__
And needs a test to catch this error
Comment #6
andypostThere's todo for this class #2915772: Deprecate non_lazy_route_enhancer service tag in favor of route_enhancer, same for non_lazy_route_filter and route_filter
Also the CR needs update https://www.drupal.org/node/2820197
Here's a patch with test, no interdiff cos it bigger then previous patch
Comment #7
Gábor HojtsyLooks good to me. The change record at https://www.drupal.org/node/2820197 does not mention anything that this patch changes. I don't think it needs to explain what this specific method does.
Comment #8
alexpottCommitted be4d1ec and pushed to 9.0.x. Thanks!