3 namespace Drupal\Core\Routing;
5 use Drupal\Core\Render\BubbleableMetadata;
6 use Symfony\Component\HttpFoundation\RequestStack;
7 use Symfony\Component\Routing\RequestContext as SymfonyRequestContext;
8 use Symfony\Component\Routing\Exception\RouteNotFoundException;
9 use Symfony\Component\Routing\Route;
12 * No-op implementation of a Url Generator, needed for backward compatibility.
14 class NullGenerator extends UrlGenerator {
17 * Override the parent constructor.
19 * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
22 public function __construct(RequestStack $request_stack) {
23 $this->requestStack = $request_stack;
24 $this->context = new RequestContext();
30 * Methods generate(), generateFromRoute() and getPathFromRoute() all call
31 * this protected method.
33 protected function getRoute($name) {
34 if ($name === '<front>') {
35 return new Route('/');
37 elseif ($name === '<current>') {
38 return new Route($this->requestStack->getCurrentRequest()->getPathInfo());
40 elseif ($name === '<none>') {
43 throw new RouteNotFoundException();
49 protected function processRoute($name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL) {
55 protected function getInternalPathFromRoute($name, Route $route, $parameters = [], &$query_params = []) {
56 return $route->getPath();
62 public function setContext(SymfonyRequestContext $context) {
68 public function getContext() {
74 protected function processPath($path, &$options = [], BubbleableMetadata $bubbleable_metadata = NULL) {