You are here

protected function CurrentPathHelper::createUrlFromRelativeUri in Menu Trail By Path 8

Create a Url Object from a relative uri (e.g. /news/drupal8-release-party)

Parameters

$relativeUri:

Return value

Url

2 calls to CurrentPathHelper::createUrlFromRelativeUri()
CurrentPathHelper::getCurrentPathUrls in src/Path/CurrentPathHelper.php
CurrentPathHelper::getCurrentRequestUrl in src/Path/CurrentPathHelper.php
Returns the current request Url

File

src/Path/CurrentPathHelper.php, line 107

Class

CurrentPathHelper

Namespace

Drupal\menu_trail_by_path\Path

Code

protected function createUrlFromRelativeUri($relativeUri) {

  // @see https://www.drupal.org/node/2810961
  if (UrlHelper::isExternal(substr($relativeUri, 1))) {
    return Url::fromUri('base:' . $relativeUri);
  }
  $relativeUri = str_replace('//', '/', $relativeUri);
  return Url::fromUserInput($relativeUri);
}