Created
May 3, 2020 11:05
-
-
Save anvodev/3fbe1bf8c9b1d72352bea9f796f02ec2 to your computer and use it in GitHub Desktop.
RouterListener::onKernelRequest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //vendor/symfony/http-kernel/EventListener/RouterListener.php | |
| public function onKernelRequest(RequestEvent $event) | |
| { | |
| $request = $event->getRequest(); | |
| // add attributes based on the request (routing) | |
| try { | |
| $parameters = $this->matcher->matchRequest($request); | |
| $request->attributes->add($parameters); | |
| unset($parameters['_route'], $parameters['_controller']); | |
| $request->attributes->set('_route_params', $parameters); | |
| } catch (ResourceNotFoundException $e) { | |
| $message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo()); | |
| throw new NotFoundHttpException($message, $e); | |
| } catch (MethodNotAllowedException $e) { | |
| $message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), implode(', ', $e->getAllowedMethods())); | |
| throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment