Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
3a10d518
Commit
3a10d518
authored
May 16, 2012
by
Niklas Fiekas
Committed by
Larry Garfield
May 19, 2012
Browse files
Clean-up UrlMatcher.php.
parent
b5d1b095
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/EventSubscriber/RouterListener.php
View file @
3a10d518
...
...
@@ -46,7 +46,7 @@ public function onKernelRequest(GetResponseEvent $event) {
if
(
HttpKernelInterface
::
MASTER_REQUEST
===
$event
->
getRequestType
())
{
$this
->
urlMatcher
->
getContext
()
->
fromRequest
(
$request
);
$this
->
urlMatcher
->
setRequest
(
$
event
->
getR
equest
()
);
$this
->
urlMatcher
->
setRequest
(
$
r
equest
);
}
if
(
$request
->
attributes
->
has
(
'_controller'
))
{
...
...
core/lib/Drupal/Core/UrlMatcher.php
View file @
3a10d518
...
...
@@ -35,6 +35,9 @@ class UrlMatcher implements UrlMatcherInterface {
*/
protected
$request
;
/**
* Constructor.
*/
public
function
__construct
()
{
// We will not actually use this object, but it's needed to conform to
// the interface.
...
...
@@ -71,10 +74,25 @@ public function getContext() {
return
$this
->
context
;
}
/**
* Sets the request object to use.
*
* This is used by the RouterListener to make additional request attributes
* available.
*
* @param Symfony\Component\HttpFoundation\Request $request
* The request object.
*/
public
function
setRequest
(
Request
$request
)
{
$this
->
request
=
$request
;
}
/**
* Gets the request object.
*
* @return Symfony\Component\HttpFoundation\Request $request
* The request object.
*/
public
function
getRequest
()
{
return
$this
->
request
;
}
...
...
@@ -105,7 +123,7 @@ public function match($pathinfo) {
}
/**
* Get a
d
rupal menu item.
* Get a
D
rupal menu item.
*
* @todo Make this return multiple possible candidates for the resolver to
* consider.
...
...
@@ -121,18 +139,28 @@ protected function matchDrupalItem($path) {
return
menu_get_item
(
$path
);
}
/**
* Converts a Drupal menu item to a route array.
*
* @param array $router_item
* The Drupal menu item.
*
* @return
* An array of parameters.
*/
protected
function
convertDrupalItem
(
$router_item
)
{
$route
=
array
(
'_controller'
=>
$router_item
[
'page_callback'
]
);
// @todo menu_get_item() does not unserialize page arguments when the access
// is denied. Remove this temporary hack that always does that.
if
(
!
is_array
(
$router_item
[
'page_arguments'
]))
{
$router_item
[
'page_arguments'
]
=
unserialize
(
$router_item
[
'page_arguments'
]);
}
// Place argument defaults on the route.
// @todo For some reason drush test runs have a serialized page_arguments
// but HTTP requests are unserialized. Hack to get around this for now.
// This might be because page arguments aren't unserialized in
// menu_get_item() when the access is denied.
!
is_array
(
$router_item
[
'page_arguments'
])
?
$page_arguments
=
unserialize
(
$router_item
[
'page_arguments'
])
:
$page_arguments
=
$router_item
[
'page_arguments'
];
foreach
(
$page_arguments
as
$k
=>
$v
)
{
foreach
(
$router_item
[
'page_arguments'
]
as
$k
=>
$v
)
{
$route
[
$k
]
=
$v
;
}
return
$route
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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