- π¦πΊAustralia acbramley
Big +1 for this, it's always bugged me that the Url object is responsible for this.
HTML attributes are currently set in \Drupal\Core\Url, instead of the \Drupal\Core\Utility\LinkGenerator. \Drupal:l()
only accepts 2 parameters $text
and Url $url
. This means when creating a link, you end up doing something like this:
$external_url = Url::fromUri('http://www.drupal.org');
$external_url->setOption('attributes', array('class' => array('my-class')));
\Drupal::l('Drupal Homepage', $external_url);
If I wanted to print that link twice with a separate set of html attributes, I either have to remove attributes, clone the obj before adding attributes, or create a new URL.
It seems me that Url(or UrlGenerator) should be responsible for 'query', 'fragment', etc... Meanwhile LinkGenerator should be responsible for html attributes 'class', 'target', etc..
Active
11.0 π₯
routing system
Enhances developer experience.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Big +1 for this, it's always bugged me that the Url object is responsible for this.