Cleaning up _current_path() and request() related stuff
parent
6d64268e50
commit
faba05fccc
|
@ -1632,6 +1632,9 @@ function request(Request $new_request = NULL) {
|
|||
if ($new_request) {
|
||||
$request = $new_request;
|
||||
}
|
||||
elseif (drupal_container()->has('request')) {
|
||||
$request = drupal_container()->get('request');
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
|
||||
|
|
|
@ -358,6 +358,9 @@ function drupal_match_path($path, $patterns) {
|
|||
* @see request_path()
|
||||
*/
|
||||
function current_path() {
|
||||
if (drupal_container()->has('request')) {
|
||||
return drupal_container()->get('request')->attributes->get('system_path');
|
||||
}
|
||||
return _current_path();
|
||||
}
|
||||
|
||||
|
|
|
@ -69,9 +69,6 @@ class PathSubscriber extends PathListenerBase implements EventSubscriberInterfac
|
|||
* The Event to process.
|
||||
*/
|
||||
public function onKernelRequestLanguageResolve(GetResponseEvent $event) {
|
||||
$request = $event->getRequest();
|
||||
$path = $this->extractPath($request);
|
||||
|
||||
// drupal_language_initialize() combines:
|
||||
// - Determination of language from $request information (e.g., path).
|
||||
// - Determination of language from other information (e.g., site default).
|
||||
|
@ -81,9 +78,6 @@ class PathSubscriber extends PathListenerBase implements EventSubscriberInterfac
|
|||
// prior to front page and alias resolution. When above is decoupled, also
|
||||
// add 'langcode' (determined from $request only) to $request->attributes.
|
||||
drupal_language_initialize();
|
||||
$path = _current_path();
|
||||
|
||||
$this->setPath($request, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -225,7 +225,9 @@ function language_from_url($languages, $args = array()) {
|
|||
}
|
||||
|
||||
list($language, $path) = language_url_split_prefix($current_path, $languages);
|
||||
_current_path($path);
|
||||
if ($request) {
|
||||
$request->attributes->set('system_path', $path);
|
||||
}
|
||||
if ($language !== FALSE) {
|
||||
$language_url = $language->langcode;
|
||||
}
|
||||
|
|
|
@ -499,7 +499,6 @@ function user_page() {
|
|||
if ($user->uid) {
|
||||
// @todo: Cleaner sub request handling.
|
||||
$subrequest = Request::create('/user/' . $user->uid, 'GET', request()->query->all(), request()->cookies->all(), array(), request()->server->all());
|
||||
request($subrequest);
|
||||
return drupal_container()->get('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -25,11 +25,6 @@ drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
|
|||
// Create a request object from the HTTPFoundation.
|
||||
$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);
|
||||
|
||||
// Bootstrap all of Drupal's subsystems, but do not initialize anything that
|
||||
// depends on the fully resolved Drupal path, because path resolution happens
|
||||
// during the REQUEST event of the kernel.
|
||||
|
|
Loading…
Reference in New Issue