diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index 975ca70..df1fbff 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -122,6 +122,9 @@ public static function createFromPath($path) { else { // Look up the route name and parameters used for the given path. try { + // Path aliases are added on the request level, so we need to manually + // call it. + // @see \Drupal\Core\EventSubscriber\PathSubscriber $path = \Drupal::service('path.alias_manager.cached')->getPathByAlias($path); $result = \Drupal::service('router')->match('/' . $path); } @@ -129,7 +132,7 @@ public static function createFromPath($path) { throw new MatchingRouteNotFoundException(sprintf('No matching route could be found for the path "%s"', $path), 0, $e); } $route_name = $result[RouteObjectInterface::ROUTE_NAME]; - $route_parameters = $result['_raw_variables']->all(); + $route_parameters = isset($result['_raw_variables']) ? $result['_raw_variables']->all() : array(); } return new static($route_name, $route_parameters); } diff --git a/core/tests/Drupal/Tests/Core/UrlTest.php b/core/tests/Drupal/Tests/Core/UrlTest.php index ad332e0..aaee399 100644 --- a/core/tests/Drupal/Tests/Core/UrlTest.php +++ b/core/tests/Drupal/Tests/Core/UrlTest.php @@ -93,7 +93,7 @@ protected function setUp() { $this->pathAliasManager = $this->getMock('Drupal\Core\Path\AliasManagerInterface'); $this->pathAliasManager->expects($this->any()) - ->method('getSystemPath') + ->method('getPathByAlias') ->will($this->returnValueMap($alias_map)); $this->router = $this->getMock('Drupal\Tests\Core\Routing\TestRouterInterface');