/**
* Determines whether a path is local.
*
* @param string $url
* The internal path or external URL being linked to, such as "node/34" or
* "http://example.com/foo".
*
* @return bool
* TRUE or FALSE, where TRUE indicates a local path.
*/
protected function isLocal($url) { return !UrlHelper::
isExternal($url) || UrlHelper::
externalIsLocal($url,
$this->
getRequestContext()->
getCompleteBaseUrl());
} /**
* Returns the request context.
*
* @return \Drupal\Core\Routing\RequestContext
* The request context.
*/
protected function getRequestContext() { if (!
isset($this->requestContext
)) { $this->requestContext = \Drupal::
service('router.request_context'
);
}