Commit 151c391b authored by Crell's avatar Crell

Add the request object to a collector function for the time being. This...

Add the request object to a collector function for the time being. This requires doing a partial bootstrap to get the class loader working, since BOOTSTRAP_FULL requires the request to already be in place.
parent da00dcc3
......@@ -3,6 +3,7 @@
use Drupal\Core\Database\Database;
use Symfony\Component\ClassLoader\UniversalClassLoader;
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
use Symfony\Component\HttpFoundation\Request;
/**
* @file
......@@ -1509,6 +1510,27 @@ function request_uri() {
return $uri;
}
/**
* Returns the current global reuqest object.
*
* @todo Replace this function with a proper dependency injection container.
*
* @staticvar Request $request
* @param Request $new_request
* The new request object to store. If you are not index.php, you probably
* should not be using this parameter.
* @return Request
* The current request object.
*/
function request(Request $new_request = NULL) {
static $request;
if ($new_request) {
$request = $new_request;
}
return $request;
}
/**
* Logs an exception.
*
......
......@@ -352,7 +352,7 @@ function drupal_match_path($path, $patterns) {
* @see request_path()
*/
function current_path() {
return $_GET['q'];
return request()->attributes->get('system_path');
}
/**
......
<?php
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
/**
* @file
* The PHP page that serves all page requests on a Drupal installation.
......@@ -17,18 +11,29 @@
* See COPYRIGHT.txt and LICENSE.txt files in the "core" directory.
*/
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
/**
* Root directory of Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
// Bootstrap the lowest level of what we need.
require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
// A request object from the HTTPFoundation to tell us about the request.
$request = Request::createFromGlobals();
// Set the global $request object. This is a temporary measure to
// keep legacy utility functions working. It should be moved to a dependency
// injection container at some point.
request($request);
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$dispatcher = new EventDispatcher();
$resolver = new ControllerResolver();
......
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