Problem/Motivation

Drupal\Core\Routing\UrlGeneratorInterface::generateFromPath() is marked as deprecated before the 8.0.0 release.

In order to remove it, we must remove usages of it.

Proposed resolution

Remove usages of Drupal\Core\Routing\UrlGeneratorInterface::generateFromPath().

From the generateFromPath() docblock:

   * @deprecated in Drupal 8.0.x-dev and will be removed before Drupal 8.0.0.
   *   To generate URLs for Drupal routes (that is, most pages generated by
   *   Drupal), see UrlGeneratorInterface::generateFromRoute() instead. For
   *   non-routed local URIs relative to the base path (like robots.txt) see
   *   \Drupal\Core\Utility\UnroutedUrlAssembler.

UroutedUrlAssembler is a service:

  unrouted_url_assembler:
    class: Drupal\Core\Utility\UnroutedUrlAssembler
    arguments: ['@request_stack', '@path_processor_manager', '%filter_protocols%']

See child issues for ongoing list of removals.

Remaining tasks

Need to identify each usage here and create sub tasks for each. Check for duplicate issues.

User interface changes

API changes

Original report by @gumanist

Contributor tasks needed
Task Novice task? Contributor instructions Complete?

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because deprecated code hasn't been removed yet.
Issue priority Normal because things work before deprecation.
Prioritized changes Prioritized changes to remove deprecated code and usages.

Comments

gumanist’s picture

mirom’s picture

Assigned: Unassigned » mirom
mirom’s picture

Assigned: mirom » Unassigned
Palashvijay4O’s picture

Assigned: Unassigned » Palashvijay4O
chx’s picture

Palashvijay4O’s picture

Assigned: Palashvijay4O » Unassigned
pwolanin’s picture

@chx - we should still do it?

Let's identify each and make sub-tasks.

pwolanin’s picture

Issue summary: View changes
Issue tags: +Needs issue summary update
ianthomas_uk’s picture

Status: Active » Postponed
Issue tags: -Novice

Postponing on #2339219: [meta] Finalize URL generation API (naming, docs, deprecation). This might be novice later, but it isn't at the moment.

mile23’s picture

Status: Postponed » Active

UrlGeneratorInterface::generateFromPath() seems to be used 32 times in core.

Is it really deprecated?

pwolanin’s picture

Yes, all but one or 2 of those uses can be removed. It's really deprecated, don't use it.

pwolanin’s picture

Created 2 sub-bugs for usages easy to remove that are not in tests. A lot of the ones in tests could be removed also very easily.

The only one not immediately removable is in RedirectResponseSubscriber::getDestinationAsAbsoluteUrl(), but possibly that can be fixed using the Url class.

mile23’s picture

Ah nice, they're child issues. Thanks.

mile23’s picture

Category: Task » Bug report
Issue summary: View changes
Issue tags: -Needs issue summary update

Updated issue summary.

mile23’s picture

Title: Remove usage of Drupal/Core/Routing/UrlGeneratorInterface.php public generateFromPath($path = NULL, $options = array()) » Remove usage of deprecated UrlGeneratorInterface::generateFromPath()
mile23’s picture

Issue summary: View changes
ianthomas_uk’s picture

Status: Active » Fixed

All child issues fixed and no references to generateFromPath left in the codebase

dawehner’s picture

Nice work!

Status: Fixed » Closed (fixed)

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