Url::access

public Url::access(AccountInterface $account = NULL) Checks this Url object against applicable access check services. Determines whether the route is accessible or not. Parameters \Drupal\Core\Session\AccountInterface $account: (optional) Run access checks for this account. Defaults to the current user. Return value bool Returns TRUE if the user has access to the url, otherwise FALSE. File core/lib/Drupal/Core/Url.php, line 789 Class Url Defines an object that holds information about a U

Url::accessManager

protected Url::accessManager() Return value \Drupal\Core\Access\AccessManagerInterface File core/lib/Drupal/Core/Url.php, line 812 Class Url Defines an object that holds information about a URL. Namespace Drupal\Core Code protected function accessManager() { if (!isset($this->accessManager)) { $this->accessManager = \Drupal::service('access_manager'); } return $this->accessManager; }

Url::createFromRequest

public static Url::createFromRequest(Request $request) Returns the Url object matching a request. SECURITY NOTE: The request path is not checked to be valid and accessible by the current user to allow storing and reusing Url objects by different users. The 'path.validator' service getUrlIfValid() method should be used instead of this one if validation and access check is desired. Otherwise, 'access_manager' service checkNamedRoute() method should be used on the router name and parameters stored

Url::fromEntityUri

protected static Url::fromEntityUri(array $uri_parts, array $options, $uri) Create a new Url object for entity URIs. Parameters array $uri_parts: Parts from an URI of the form entity:{entity_type}/{entity_id} as from parse_url(). array $options: An array of options, see \Drupal\Core\Url::fromUri() for details. string $uri: The original entered URI. Return value \Drupal\Core\Url A new Url object for an entity's canonical route. Throws \InvalidArgumentException Thrown if the entity URI is inva

Url::fromInternalUri

protected static Url::fromInternalUri(array $uri_parts, array $options) Creates a new Url object for 'internal:' URIs. Important note: the URI minus the scheme can NOT simply be validated by a \Drupal\Core\Path\PathValidatorInterface implementation. The semantics of the 'internal:' URI scheme are different: PathValidatorInterface accepts paths without a leading slash (e.g. 'node/add') as well as 2 special paths: '<front>' and '<none>', which are mapped to the correspondingly named r

Url::fromRoute

public static Url::fromRoute($route_name, $route_parameters = array(), $options = array()) Creates a new Url object for a URL that has a Drupal route. This method is for URLs that have Drupal routes (that is, most pages generated by Drupal). For non-routed local URIs relative to the base path (like robots.txt) use Url::fromUri() with the base: scheme. Parameters string $route_name: The name of the route array $route_parameters: (optional) An associative array of route parameter names and value

Url::fromRouteMatch

public static Url::fromRouteMatch(RouteMatchInterface $route_match) Creates a new URL object from a route match. Parameters \Drupal\Core\Routing\RouteMatchInterface $route_match: The route match. Return value $this File core/lib/Drupal/Core/Url.php, line 152 Class Url Defines an object that holds information about a URL. Namespace Drupal\Core Code public static function fromRouteMatch(RouteMatchInterface $route_match) { if ($route_match->getRouteObject()) { return new static

Url::fromRouteUri

protected static Url::fromRouteUri(array $uri_parts, array $options, $uri) Creates a new Url object for 'route:' URIs. Parameters array $uri_parts: Parts from an 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. array $options: An array of options, see \Drupal\Core\Url::fromUri() for details. string $uri: The original passed in URI. Retu

Url::fromUri

public static Url::fromUri($uri, $options = []) Creates a new Url object from a URI. This method is for generating URLs for URIs that: do not have Drupal routes: both external URLs and unrouted local URIs like base:robots.txt do have a Drupal route but have a custom scheme to simplify linking. Currently, there is only the entity: scheme (This allows URIs of the form entity:{entity_type}/{entity_id}. For example: entity:node/1 resolves to the entity.node.canonical route with a node parameter of

Url::fromUserInput

public static Url::fromUserInput($user_input, $options = []) 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. Parameters 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