UrlMatcher.php in Drupal 10
File
core/lib/Drupal/Core/Routing/UrlMatcher.php
View source
<?php
namespace Drupal\Core\Routing;
use Drupal\Core\Path\CurrentPathStack;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Matcher\UrlMatcher as BaseUrlMatcher;
class UrlMatcher extends BaseUrlMatcher {
protected $currentPath;
public function __construct(CurrentPathStack $current_path) {
$this->currentPath = $current_path;
}
public function finalMatch(RouteCollection $collection, Request $request) {
$this->routes = $collection;
$context = new RequestContext();
$context
->fromRequest($request);
$this
->setContext($context);
return $this
->match($this->currentPath
->getPath($request));
}
protected function getAttributes(Route $route, $name, array $attributes) : array {
if ($route instanceof RouteObjectInterface && is_string($route
->getRouteKey())) {
$name = $route
->getRouteKey();
}
$attributes[RouteObjectInterface::ROUTE_NAME] = $name;
$attributes[RouteObjectInterface::ROUTE_OBJECT] = $route;
return $this
->mergeDefaults($attributes, $route
->getDefaults());
}
}
Classes
Name |
Description |
UrlMatcher |
Drupal-specific URL Matcher; handles the Drupal "system path" mapping. |