class NullGenerator

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Routing/NullGenerator.php \Drupal\Core\Routing\NullGenerator
  2. 8.9.x core/lib/Drupal/Core/Routing/NullGenerator.php \Drupal\Core\Routing\NullGenerator
  3. 11.x core/lib/Drupal/Core/Routing/NullGenerator.php \Drupal\Core\Routing\NullGenerator

No-op implementation of a URL Generator, needed for backward compatibility.

Hierarchy

Expanded class hierarchy of NullGenerator

File

core/lib/Drupal/Core/Routing/NullGenerator.php, line 13

Namespace

Drupal\Core\Routing
View source
class NullGenerator extends UrlGenerator {
  
  /**
   * Override the parent constructor.
   *
   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
   *   The request stack.
   */
  public function __construct(RequestStack $request_stack) {
    $this->requestStack = $request_stack;
    $this->context = new RequestContext();
  }
  
  /**
   * {@inheritdoc}
   *
   * Methods generate(), generateFromRoute() and getPathFromRoute() all call
   * this protected method.
   */
  protected function getRoute($name) {
    if ($name === '<front>') {
      return new Route('/');
    }
    elseif ($name === '<current>') {
      return new Route($this->requestStack
        ->getCurrentRequest()
        ->getPathInfo());
    }
    elseif ($name === '<none>') {
      return new Route('');
    }
    throw new RouteNotFoundException();
  }
  
  /**
   * {@inheritdoc}
   */
  protected function processRoute($name, Route $route, array &$parameters, ?BubbleableMetadata $bubbleable_metadata = NULL) {
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getInternalPathFromRoute($name, Route $route, $parameters = [], &$query_params = []) {
    return $route->getPath();
  }
  
  /**
   * {@inheritdoc}
   */
  protected function processPath($path, &$options = [], ?BubbleableMetadata $bubbleable_metadata = NULL) {
    return $path;
  }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title
NullGenerator::getInternalPathFromRoute protected function Gets the path of a route. Overrides UrlGenerator::getInternalPathFromRoute
NullGenerator::getRoute protected function Methods generate(), generateFromRoute() and getPathFromRoute() all call
this protected method.
Overrides UrlGenerator::getRoute
NullGenerator::processPath protected function Passes the path to a processor manager to allow alterations. Overrides UrlGenerator::processPath
NullGenerator::processRoute protected function Passes the route to the processor manager for altering before compilation. Overrides UrlGenerator::processRoute
NullGenerator::__construct public function Override the parent constructor. Overrides UrlGenerator::__construct
UrlGenerator::$context protected property
UrlGenerator::$decodedChars protected property Overrides characters that will not be percent-encoded in the path segment.
UrlGenerator::$pathProcessor protected property The path processor to convert the system path to one suitable for URLs.
UrlGenerator::$provider protected property The route provider.
UrlGenerator::$requestStack protected property A request stack object.
UrlGenerator::$routeProcessor protected property The route processor.
UrlGenerator::doGenerate protected function Substitute the route parameters into the route path.
UrlGenerator::generate public function
UrlGenerator::generateFromRoute public function Generates a URL or path for a specific route based on the given parameters. Overrides UrlGeneratorInterface::generateFromRoute
UrlGenerator::getContext public function
UrlGenerator::getPathFromRoute public function Gets the internal path (system path) for a route. Overrides UrlGeneratorInterface::getPathFromRoute
UrlGenerator::getRouteDebugMessage Deprecated public function Gets either the route name or a string based on the route object.
UrlGenerator::getRouteStringIdentifier private function Gets either the route name or a string based on the route object.
UrlGenerator::isStrictRequirements public function
UrlGenerator::setContext public function phpcs:ignore Drupal.Commenting.FunctionComment.VoidReturn
UrlGenerator::setStrictRequirements public function
UrlGenerator::supports Deprecated public function Checks if route name is a string or route object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.