Problem/Motivation

In an effort to reduce the number of ways to generate a link, we deprecated calling Router::generate() in Drupal 8.3.0

Last time we tried to remove it, we realised we couldn't because it was on RouterInterface, so we said it will start throwing an exception in Drupal 10.

  /**
   * {@inheritdoc}
   */
  public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH): string {
    @trigger_error(__METHOD__ . '() is deprecated in drupal:8.3.0 and will throw an exception from drupal:10.0.0. Use the \Drupal\Core\Url object instead. See https://www.drupal.org/node/2820197', E_USER_DEPRECATED);
    return $this->urlGenerator->generate($name, $parameters, $referenceType);
  }

I think we need to remove the @inheritdoc, add a @throws, and then have an exception message which tells people to use the Url object instead.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#3 3293284-3.patch2.69 KBcatch
#3 3293284-interdiff.txt535 bytescatch
#2 3293284.patch2.68 KBcatch

Comments

catch created an issue. See original summary.

catch’s picture

Status: Active » Needs review
StatusFileSize
new2.68 KB
catch’s picture

StatusFileSize
new535 bytes
new2.69 KB

Adding a line.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All code changes look good to me.
This is a D10 change only.
It is RTBC for me.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed c4edefd1d7 to 10.1.x and 678fdc7ff1 to 10.0.x. Thanks!

  • alexpott committed c4edefd on 10.1.x
    Issue #3293284 by catch: Throw an exception when Router::generate() is...

  • alexpott committed 678fdc7 on 10.0.x
    Issue #3293284 by catch: Throw an exception when Router::generate() is...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.