comparison vendor/symfony-cmf/routing/NestedMatcher/UrlMatcher.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 /*
4 * This file is part of the Symfony CMF package.
5 *
6 * (c) 2011-2015 Symfony CMF
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Cmf\Component\Routing\NestedMatcher;
13
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;
20
21 /**
22 * Extended UrlMatcher to provide an additional interface and enhanced features.
23 *
24 * This class requires Symfony 2.2 for a refactoring done to the symfony UrlMatcher
25 *
26 * @author Larry Garfield
27 */
28 class UrlMatcher extends SymfonyUrlMatcher implements FinalMatcherInterface
29 {
30 /**
31 * {@inheritdoc}
32 */
33 public function finalMatch(RouteCollection $collection, Request $request)
34 {
35 $this->routes = $collection;
36 $context = new RequestContext();
37 $context->fromRequest($request);
38 $this->setContext($context);
39
40 return $this->match($request->getPathInfo());
41 }
42
43 /**
44 * {@inheritdoc}
45 */
46 protected function getAttributes(Route $route, $name, array $attributes)
47 {
48 if ($route instanceof RouteObjectInterface && is_string($route->getRouteKey())) {
49 $name = $route->getRouteKey();
50 }
51 $attributes[RouteObjectInterface::ROUTE_NAME] = $name;
52 $attributes[RouteObjectInterface::ROUTE_OBJECT] = $route;
53
54 return $this->mergeDefaults($attributes, $route->getDefaults());
55 }
56 }