throw new \
InvalidArgumentException("The internal path component '{
$uri_parts['path'
]}' is invalid. Its path component must have a leading slash, e.g. internal:/foo."
);
} // Remove the leading slash.
$uri_parts['path'
] =
substr($uri_parts['path'
], 1
);
if (UrlHelper::
isExternal($uri_parts['path'
])) { throw new \
InvalidArgumentException("The internal path component '{
$uri_parts['path'
]}' is external. You are not allowed to specify an external URL together with internal:/."
);
} } $url = \Drupal::
pathValidator() ->
getUrlIfValidWithoutAccessCheck($uri_parts['path'
]) ?:
static::
fromUri('base:' .
$uri_parts['path'
],
$options);
// Allow specifying additional options.
$url->
setOptions($options +
$url->
getOptions());
return $url;
} /**
* Creates a new Url object for 'route:' URIs.
*
* @param array $uri_parts
* Parts from a URI of the form route:{route_name};{route_parameters} as
* from parse_url(), where the path is the route name optionally followed by
* a ";" followed by route parameters in key=value format with & separators.
* @param array $options
* An array of options, see \Drupal\Core\Url::fromUri() for details.
* @param string $uri
* The original passed in URI.
*
* @return static
* A new Url object for a 'route:' URI.
*
* @throws \InvalidArgumentException
* Thrown when the route URI does not have a route name.
*/