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
For the following classes:
- \Drupal\Core\Url
- \Drupal\Core\Link
- \Drupal\Core\Utility\UnroutedUrlAssembler (added in #2343759: Provide an API function to replace url()/l() for external urls)
- \Drupal\Core\Utility\LinkGenerator
- UrlGenerator
We should decide where to put these classes for better decoupling and/or more explicit dependencies when the dependencies do exist.
Proposed resolution
- Decide on the correct locations for these classes.
- To preserve BC, the existing classes should become direct, deprecated subclasses of the correct location. For example, if we decide Url should go in NewNamespace:
namespace Drupal\Core; /** * Defines an object that holds information about a URL. * * @deprecated as of 8.0.0 and will be removed 9.x. Use Drupal\NewNamespace\Url instead. */ class Url extends Drupal\NewNamespace\Url { }
Then core just adds the updated
use
statements as needed.
Remaining tasks
Decide what to do, then patch.
User interface changes
None.
API changes
No BC break.
Comments
Comment #1
xjmComment #2
Crell CreditAttribution: Crell commentedIt's debatable if we want to later kill the old stub classes or leave them for the entire length of D8. I'd be OK with killing them in a week or three.
UrlGenerator belongs in Routing, no question.
Comment #3
tim.plunkettSee also #2346431: Move LinkGenerator out of Drupal\Core\Utility, LinkGenerator is NOT top level like the IS stated.
Comment #4
tim.plunkettComment #5
dawehnerTechnically the URL object depends on the concept of route names so it has an implicit dependency to the routing system. Given that, URL
should be part of Routing if you ask me. Based upon that the link generator should be part of routing as well, as it depends on the URL object.
The same points work for the Link object as well.
The
UnroutedUrlAssembler
itself could be somewhere else, not sure though whether it is worth in terms of coherence.Comment #6
tim.plunkettWe're not moving them now. We can move them in 8.1.x and leave stubs in the old namespace...