Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
71cf6406
Commit
71cf6406
authored
May 06, 2012
by
Crell
Browse files
Automatically urldecode() paths to allow for useful data in path fragments.
parent
2ceb9c02
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
View file @
71cf6406
...
...
@@ -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
(
'onKernelRequest
PathResolve
'
,
10
0
);
$events
[
KernelEvents
::
REQUEST
][]
=
array
(
'onKernelRequest
DecodePath
'
,
10
2
);
$events
[
KernelEvents
::
REQUEST
][]
=
array
(
'onKernelRequestFrontPageResolve'
,
101
);
$events
[
KernelEvents
::
REQUEST
][]
=
array
(
'onKernelRequestPathResolve'
,
100
);
return
$events
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment