/**
* Creates a new URL object from a route match.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route match.
*
* @return static
*/
public static function fromRouteMatch(RouteMatchInterface
$route_match) { if ($route_match->
getRouteObject()) { return new static($route_match->
getRouteName(),
$route_match->
getRawParameters()->
all());
} else { throw new \
InvalidArgumentException('Route required'
);
} } /**
* Creates a Url object for a relative URI reference submitted by user input.
*
* Use this method to create a URL for user-entered paths that may or may not
* correspond to a valid Drupal route.
*
* @param string $user_input
* User input for a link or path. The first character must be one of the
* following characters:
* - '/': A path within the current site. This path might be to a Drupal
* route (e.g., '/admin'), to a file (e.g., '/README.txt'), or to
* something processed by a non-Drupal script (e.g.,
* '/not/a/drupal/page'). If the path matches a Drupal route, then the
* URL generation will include Drupal's path processors (e.g.,
* language-prefixing and aliasing). Otherwise, the URL generation will
* just append the passed-in path to Drupal's base path.
* - '?': A query string for the current page or resource.
* - '#': A fragment (jump-link) on the current page or resource.
* This helps reduce ambiguity for user-entered links and paths, and
* supports user interfaces where users may normally use auto-completion
* to search for existing resources, but also may type one of these
* characters to link to (e.g.) a specific path on the site.
* (With regard to the URI specification, the user input is treated as a
* @link https://tools.ietf.org/html/rfc3986#section-4.2 relative URI reference @endlink
* where the relative part is of type
* @link https://tools.ietf.org/html/rfc3986#section-3.3 path-abempty @endlink.)
* @param array $options
* (optional) An array of options. See Url::fromUri() for details.
*
* @return static
* A new Url object based on user input.
*
* @throws \InvalidArgumentException
* Thrown when the user input does not begin with one of the following
* characters: '/', '?', or '#'.
*/