merged branch fabpot/referer-in-404 (PR #8708)

This PR was merged into the master branch.

Discussion
----------

Add the referer information that could help you findout where's the link comes from

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

#8218 rebased on master and slightly tweaked.

Commits
-------

8eb163d [HttpKernel] tweaked previous commit
bb5954e Add the referer information that could help you findout where's the link comes from.
This commit is contained in:
Fabien Potencier 2013-08-10 21:56:33 +02:00
commit 43e066f7ab

View File

@ -113,6 +113,10 @@ class RouterListener implements EventSubscriberInterface
} catch (ResourceNotFoundException $e) {
$message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo());
if ($referer = $request->headers->get('referer')) {
$message .= sprintf(' (from "%s")', $referer);
}
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(), strtoupper(implode(', ', $e->getAllowedMethods())));