UrlGeneratorTrait

Wrapper methods for the Url Generator. This utility trait should only be used in application-level code, such as classes that would implement ContainerInjectionInterface. Services registered in the Container should not use this trait but inject the appropriate service directly for easier testing. Hierarchy trait \Drupal\Core\Routing\UrlGeneratorTrait Deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Url instead. File core/lib/Drupal/Core/Routing/UrlGener

UrlGeneratorTrait::$urlGenerator

The url generator. Type: \Drupal\Core\Routing\UrlGeneratorInterface File core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php, line 25 Class UrlGeneratorTrait Wrapper methods for the Url Generator. Namespace Drupal\Core\Routing Code protected $urlGenerator;

UrlGeneratorTrait::getUrlGenerator

protected UrlGeneratorTrait::getUrlGenerator() Returns the URL generator service. Return value \Drupal\Core\Routing\UrlGeneratorInterface The URL generator service. File core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php, line 73 Class UrlGeneratorTrait Wrapper methods for the Url Generator. Namespace Drupal\Core\Routing Code protected function getUrlGenerator() { if (!$this->urlGenerator) { $this->urlGenerator = \Drupal::service('url_generator'); } return $this->ur

UrlGeneratorTrait::redirect

protected UrlGeneratorTrait::redirect($route_name, array $route_parameters = [], array $options = [], $status = 302) Returns a redirect response object for the specified route. Parameters string $route_name: The name of the route to which to redirect. array $route_parameters: (optional) Parameters for the route. array $options: (optional) An associative array of additional options. int $status: (optional) The HTTP redirect status code for the redirect. The default is 302 Found. Return value \

UrlGeneratorTrait::setUrlGenerator

public UrlGeneratorTrait::setUrlGenerator(UrlGeneratorInterface $generator) Sets the URL generator service. Parameters \Drupal\Core\Routing\UrlGeneratorInterface $generator: The url generator service. Return value $this File core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php, line 88 Class UrlGeneratorTrait Wrapper methods for the Url Generator. Namespace Drupal\Core\Routing Code public function setUrlGenerator(UrlGeneratorInterface $generator) { $this->urlGenerator = $generator

UrlGeneratorTrait::url

protected UrlGeneratorTrait::url($route_name, $route_parameters = array(), $options = array()) Generates a URL or path for a specific route based on the given parameters. For details on the arguments, usage, and possible exceptions see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute(). Return value string The generated URL for the given route. Deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Url instead. See also \Drupal\Core\Routing\UrlGen

UrlHelper

Helper class URL based methods. Hierarchy class \Drupal\Component\Utility\UrlHelper Related topics Utility classes and functions Overview of utility classes and functions for developers. File core/lib/Drupal/Component/Utility/UrlHelper.php, line 10 Namespace Drupal\Component\Utility Members Name Modifiers Type Description UrlHelper::$allowedProtocols protected static property The list of allowed protocols. UrlHelper::buildQuery public static function Parses an

UrlHelper::$allowedProtocols

The list of allowed protocols. Type: array File core/lib/Drupal/Component/Utility/UrlHelper.php, line 17 Class UrlHelper Helper class URL based methods. Namespace Drupal\Component\Utility Code protected static $allowedProtocols = array('http', 'https');

UrlHelper::buildQuery

public static UrlHelper::buildQuery(array $query, $parent = '') Parses an array into a valid, rawurlencoded query string. rawurlencode() is RFC3986 compliant, and as a consequence RFC3987 compliant. The latter defines the required format of "URLs" in HTML5. urlencode() is almost the same as rawurlencode(), except that it encodes spaces as "+" instead of "%20". This makes its result non compliant to RFC3986 and as a consequence non compliant to RFC3987 and as a consequence not valid as a "URL" i

UrlHelper::encodePath

public static UrlHelper::encodePath($path) Encodes a Drupal path for use in a URL. For aesthetic reasons slashes are not escaped. Parameters string $path: The Drupal path to encode. Return value string The encoded path. File core/lib/Drupal/Component/Utility/UrlHelper.php, line 193 Class UrlHelper Helper class URL based methods. Namespace Drupal\Component\Utility Code public static function encodePath($path) { return str_replace('%2F', '/', rawurlencode($path)); }