Problem/Motivation

There are a couple of usecases for generating links/urls.

  • You want to generate an URL to a path controlled by drupal: (new URL($route_name))->toString()
  • You want to generate an external URL, just (new URL($external_url))->toString()
  • Generate a link with a given route: LinkGeneratorInterface->generate($text, $route_name)
  • Generate a ink to an external path, path without a route: l()

Proposed resolution

Let's reuse most of the logic of the link generator for the l method(). Introduces LinkGeneratorInterface->generateFromPath($path)

Remaining tasks

User interface changes

API changes

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new7.89 KB

Status: Needs review » Needs work

The last submitted patch, 1: link_generator-2306901-1.patch, failed testing.

Crell’s picture

Issue summary: View changes

Adding issue summary. +1 on this.

If l() isn't already marked @deprecated, this issue should mark it as such.

dawehner’s picture

Issue summary: View changes

.

dawehner’s picture

StatusFileSize
new8.29 KB
new1.05 KB

Let's see whether catching the exception would work.

Crell’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: link_generator-2306901-5.patch, failed testing.

xjm’s picture

dawehner’s picture

Status: Needs work » Needs review
Related issues: -#2221771: Mark all simple wrappers in bootstrap.inc and common.inc as deprecated
StatusFileSize
new8.33 KB

Let's reroll and see what is going on.

Status: Needs review » Needs work

The last submitted patch, 9: link_generator-2306901-8.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new11.35 KB

Let's do it as simple as possible now, just move over the content.

Crell’s picture

This contains the API change; any further refactoring shouldn't impact the API so I'm fine with it as is, with non-critical followups to clean up the code if we feel like it. My one question is the method name. "uriReference" is not at all what I would have thought to call the thing we're passing to the method. Can we think briefly on a better name (and if we can't find one, screw it, let's not bikeshed for too long)?

effulgentsia’s picture

Is there anything here that's still relevant?

dawehner’s picture

Status: Needs review » Fixed

No, its not, juhuu

xjm’s picture

Status: Fixed » Closed (duplicate)

Duplicate actually I think