4 * This file is part of the Symfony CMF package.
6 * (c) 2011-2015 Symfony CMF
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Cmf\Component\Routing\NestedMatcher;
14 use Symfony\Component\Routing\Route;
15 use Symfony\Component\Routing\RouteCollection;
16 use Symfony\Component\Routing\Matcher\UrlMatcher as SymfonyUrlMatcher;
17 use Symfony\Component\HttpFoundation\Request;
18 use Symfony\Component\Routing\RequestContext;
19 use Symfony\Cmf\Component\Routing\RouteObjectInterface;
22 * Extended UrlMatcher to provide an additional interface and enhanced features.
24 * This class requires Symfony 2.2 for a refactoring done to the symfony UrlMatcher
26 * @author Larry Garfield
28 class UrlMatcher extends SymfonyUrlMatcher implements FinalMatcherInterface
33 public function finalMatch(RouteCollection $collection, Request $request)
35 $this->routes = $collection;
36 $context = new RequestContext();
37 $context->fromRequest($request);
38 $this->setContext($context);
40 return $this->match($request->getPathInfo());
46 protected function getAttributes(Route $route, $name, array $attributes)
48 if ($route instanceof RouteObjectInterface && is_string($route->getRouteKey())) {
49 $name = $route->getRouteKey();
51 $attributes[RouteObjectInterface::ROUTE_NAME] = $name;
52 $attributes[RouteObjectInterface::ROUTE_OBJECT] = $route;
54 return $this->mergeDefaults($attributes, $route->getDefaults());