UrlMatcher.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Drupal\Core\Routing;
  3. use Drupal\Core\Path\CurrentPathStack;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\Routing\RouteCollection;
  6. use Symfony\Cmf\Component\Routing\NestedMatcher\UrlMatcher as BaseUrlMatcher;
  7. /**
  8. * Drupal-specific URL Matcher; handles the Drupal "system path" mapping.
  9. */
  10. class UrlMatcher extends BaseUrlMatcher {
  11. /**
  12. * The current path.
  13. *
  14. * @var \Drupal\Core\Path\CurrentPathStack
  15. */
  16. protected $currentPath;
  17. /**
  18. * Constructs a new UrlMatcher.
  19. *
  20. * The parent class has a constructor we need to skip, so just override it
  21. * with a no-op.
  22. *
  23. * @param \Drupal\Core\Path\CurrentPathStack $current_path
  24. * The current path.
  25. */
  26. public function __construct(CurrentPathStack $current_path) {
  27. $this->currentPath = $current_path;
  28. }
  29. public function finalMatch(RouteCollection $collection, Request $request) {
  30. $this->routes = $collection;
  31. $context = new RequestContext();
  32. $context->fromRequest($request);
  33. $this->setContext($context);
  34. return $this->match($this->currentPath->getPath($request));
  35. }
  36. }