Commit 3a10d518 authored by Niklas Fiekas's avatar Niklas Fiekas Committed by Crell

Clean-up UrlMatcher.php.

parent b5d1b095
......@@ -46,7 +46,7 @@ public function onKernelRequest(GetResponseEvent $event) {
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
$this->urlMatcher->getContext()->fromRequest($request);
$this->urlMatcher->setRequest($event->getRequest());
$this->urlMatcher->setRequest($request);
}
if ($request->attributes->has('_controller')) {
......
......@@ -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 drupal menu item.
* Get a Drupal 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;
......
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