| @@ 67-84 (lines=18) @@ | ||
| 64 | * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException |
|
| 65 | * @throws \Symfony\Component\Routing\Exception\MethodNotAllowedException |
|
| 66 | */ |
|
| 67 | public function match(RouteCollectionInterface $routes, $method, $requestTarget) |
|
| 68 | { |
|
| 69 | $response = ['response']; |
|
| 70 | $symfonyRoutes = $this->getSymfonyRouteCollection($routes); |
|
| 71 | ||
| 72 | $context = new RequestContext('/'); |
|
| 73 | ||
| 74 | $matcher = new UrlMatcher($symfonyRoutes, $context); |
|
| 75 | ||
| 76 | $parameters = $matcher->match($requestTarget); |
|
| 77 | // array('_controller' => 'MyController', '_route' => 'route_name') |
|
| 78 | ||
| 79 | if (!isset($parameters['controller'])) { |
|
| 80 | $response['statusCode'] = 404; |
|
| 81 | } |
|
| 82 | ||
| 83 | return $this->createRouterResponse($response); |
|
| 84 | } |
|
| 85 | ||
| 86 | public function getSymfonyRouteCollection(RouteCollectionInterface $routes) |
|
| 87 | { |
|
| @@ 72-89 (lines=18) @@ | ||
| 69 | * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException |
|
| 70 | * @throws \Symfony\Component\Routing\Exception\MethodNotAllowedException |
|
| 71 | */ |
|
| 72 | public function match(RouteCollectionInterface $routes, $method, $requestTarget) |
|
| 73 | { |
|
| 74 | $response = ['response']; |
|
| 75 | $symfonyRoutes = $this->createSymfonyRouteCollection($routes); |
|
| 76 | ||
| 77 | $context = new RequestContext('/'); |
|
| 78 | ||
| 79 | $matcher = new UrlMatcher($symfonyRoutes, $context); |
|
| 80 | ||
| 81 | $parameters = $matcher->match($requestTarget); |
|
| 82 | // array('_controller' => 'MyController', '_route' => 'route_name') |
|
| 83 | ||
| 84 | if (!isset($parameters['controller'])) { |
|
| 85 | $response['statusCode'] = 404; |
|
| 86 | } |
|
| 87 | ||
| 88 | return $this->createRouterResponse($response); |
|
| 89 | } |
|
| 90 | ||
| 91 | public function createSymfonyRouteCollection(RouteCollectionInterface $routes) |
|
| 92 | { |
|