NullGenerator.php in Drupal 9
File
core/lib/Drupal/Core/Routing/NullGenerator.php
View source
<?php
namespace Drupal\Core\Routing;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RequestContext as SymfonyRequestContext;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Route;
class NullGenerator extends UrlGenerator {
public function __construct(RequestStack $request_stack) {
$this->requestStack = $request_stack;
$this->context = new RequestContext();
}
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();
}
protected function processRoute($name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL) {
}
protected function getInternalPathFromRoute($name, Route $route, $parameters = [], &$query_params = []) {
return $route
->getPath();
}
public function setContext(SymfonyRequestContext $context) {
}
public function getContext() {
}
protected function processPath($path, &$options = [], BubbleableMetadata $bubbleable_metadata = NULL) {
return $path;
}
}
Classes
Name |
Description |
NullGenerator |
No-op implementation of a Url Generator, needed for backward compatibility. |