class NullGenerator in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Routing/NullGenerator.php \Drupal\Core\Routing\NullGenerator
- 9 core/lib/Drupal/Core/Routing/NullGenerator.php \Drupal\Core\Routing\NullGenerator
No-op implementation of a Url Generator, needed for backward compatibility.
Hierarchy
- class \Drupal\Core\Routing\NullGenerator extends \Drupal\Core\Routing\UrlGenerator
Expanded class hierarchy of NullGenerator
File
- core/
lib/ Drupal/ Core/ Routing/ NullGenerator.php, line 13
Namespace
Drupal\Core\RoutingView 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;
}
}