Commit 71cf6406 authored by Crell's avatar Crell
Browse files

Automatically urldecode() paths to allow for useful data in path fragments.

parent 2ceb9c02
......@@ -68,6 +68,31 @@ public function onKernelRequestFrontPageResolve(GetResponseEvent $event) {
$this->setPath($request, $path);
}
/**
* Decodes the path of the request.
*
* Parameters in the URL sometimes represent code-meaningful strings. It is
* therefore useful to always urldecode() those values so that individual
* controllers need not concern themselves with it. This is Drupal-specific
* logic, and may not be familiar for developers used to other Symfony-family
* projects.
*
* @todo Revisit whether or not this logic is appropriate for here or if
* controllers should be required to implement this logic themselves. If
* we decide to keep this code, remove this TODO.
*
* @param GetResponseEvent $event
* The Event to process.
*/
public function onKernelRequestDecodePath(GetResponseEvent $event) {
$request = $event->getRequest();
$path = $this->extractPath($request);
$path = urldecode($path);
$this->setPath($request, $path);
}
/**
* Registers the methods in this class that should be listeners.
*
......@@ -75,8 +100,9 @@ public function onKernelRequestFrontPageResolve(GetResponseEvent $event) {
* An array of event listener definitions.
*/
static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = array('onKernelRequestPathResolve', 100);
$events[KernelEvents::REQUEST][] = array('onKernelRequestDecodePath', 102);
$events[KernelEvents::REQUEST][] = array('onKernelRequestFrontPageResolve', 101);
$events[KernelEvents::REQUEST][] = array('onKernelRequestPathResolve', 100);
return $events;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment