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.
Followup from #2343759: Provide an API function to replace url()/l() for external urls. Part of #2339219: [meta] Finalize URL generation API (naming, docs, deprecation).
Problem/Motivation
In a few places in #2343759: Provide an API function to replace url()/l() for external urls, we do this:
strpos($this->uri, 'base://') !== 0)
Proposed resolution
Add a method for this.
Remaining tasks
- Decide what to name it.
- Add it.
- Convert things to it.
User interface changes
None.
API changes
API addition only.
Postponed until
#2343759: Provide an API function to replace url()/l() for external urls
Comment | File | Size | Author |
---|---|---|---|
#6 | provide_a_method_for-2346859-6.patch | 592 bytes | hussainweb |
Comments
Comment #1
tim.plunkettComment #2
kgoel CreditAttribution: kgoel commentedI have found only one occurrence of
strpos($this->uri, 'base://') !== 0)
in core/Url.php. Is this issue still relevant?Comment #3
effulgentsia CreditAttribution: effulgentsia commentedWe have that. It's
isExternal()
:)Per #2, it's down to one place, which is necessary, since isExternal() needs some implementation.
I don't think so. Marking fixed since the other places have been fixed via some other issues after this was originally opened.
Comment #4
effulgentsia CreditAttribution: effulgentsia commentedCorrection: if you specifically want to know whether it's not routed and not external, you can call
!$url->isRouted() && !$url->isExternal()
. I don't think we need a single-method wrapper for that: those are two different checks so can remain distinct.Comment #5
hussainwebIt seems like a good idea to remove the comment leading to this issue in
\Drupal\Core\Url::setUnrouted()
. Should we do it in this issue?Comment #6
hussainwebJust giving it a shot. I can't think of any other issue better suited to remove the comment.
Comment #7
hussainwebMarking it as a quickfix, and a minor issue, which it is. :)
Comment #8
xjmThis is actually going to end up as a duplicate of #2416763: Convert Url::fromUri() base:// scheme to base: now, which will refactor the lines with the @todo.