Inherits beta evaluation from parent issue: #2367749: Remove usage of deprecated UrlGeneratorInterface::generateFromPath()

Problem/Motivation

UrlGeneratorInterface::generateFromPath() is deprecated for removal before Drupal 8.0.0 release.

LanguageSwitchingTest::testLanguageBlockWithDomain() calls UrlGeneratorInterface::generateFromPath() with a path instead of using a route name.

There might be other instances in the language module where UrlGeneratorInterface::generateFromPath() is used.

These should all be removed.

Proposed resolution

Fix by changing the method call to generateFromRoute() with a route name and parameters

Remaining tasks

User interface changes

n/a

API changes

n/a

Contributor tasks needed
Task Novice task? Contributor instructions Complete?

Comments

Mile23 created an issue. See original summary.

mile23’s picture

Issue summary: View changes
sdstyles’s picture

Status: Active » Needs review
StatusFileSize
new1.14 KB
sdstyles’s picture

StatusFileSize
new1.16 KB
new1.05 KB

Passed language parameter as option.

The last submitted patch, 3: 2558187-3.patch, failed testing.

mile23’s picture

+++ b/core/modules/language/src/Tests/LanguageSwitchingTest.php
@@ -210,7 +210,7 @@ function testLanguageBlockWithDomain() {
-    $english_url = $generator->generateFromPath('user/2', array('language' => $languages['en']));
+    $english_url = $generator->generateFromRoute('user/2', array(), array('language' => $languages['en']));

If you look at the failing test, you'll see that it failed because it threw an exception:
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "user/2" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 193 of /var/lib/drupaltestbot/sites/default/files/checkout/core/lib/Drupal/Core/Routing/RouteProvider.php). Drupal\Core\Routing\RouteProvider->getRouteByName('user/2') Drupal\Core\Routing\UrlGenerator->getRoute('user/2') Drupal\Core\Routing\UrlGenerator->generateFromRoute('user/2', Array, Array, 1) Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('user/2', Array) Drupal\language\Tests\LanguageSwitchingTest->testLanguageBlockWithDomain() Drupal\simpletest\TestBase->run(Array) simpletest_script_run_one_test('596', 'Drupal\language\Tests\LanguageSwitchingTest')

This tells you that there's no *route* named 'user/2'.

generateFromRoute() requires a route name, not a path.

Status: Needs review » Needs work

The last submitted patch, 4: 2558187-4.patch, failed testing.

sdstyles’s picture

Status: Needs work » Needs review
StatusFileSize
new1.58 KB
new1.52 KB

Changed path with route and fixed typo.

mile23’s picture

Status: Needs review » Reviewed & tested by the community

Nice.

Applies, passes tests, and is needed for a deprecation before the 8.0.0 release.

See the parent issue for beta evaluation: #2367749: Remove usage of deprecated UrlGeneratorInterface::generateFromPath()

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

tbh all the simple UrlGeneratorInterface::generateFromPath() could have been done in one usages.

Committed f3f3efa and pushed to 8.0.x. Thanks!

  • alexpott committed f3f3efa on 8.0.x
    Issue #2558187 by sdstyles: Remove usage of UrlGeneratorInterface::...

Status: Fixed » Closed (fixed)

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