Skip to content
Snippets Groups Projects
Commit faba05fc authored by Katherine Bailey's avatar Katherine Bailey
Browse files

Cleaning up _current_path() and request() related stuff

parent 6d64268e
No related branches found
No related tags found
No related merge requests found
...@@ -1632,6 +1632,9 @@ function request(Request $new_request = NULL) { ...@@ -1632,6 +1632,9 @@ function request(Request $new_request = NULL) {
if ($new_request) { if ($new_request) {
$request = $new_request; $request = $new_request;
} }
elseif (drupal_container()->has('request')) {
$request = drupal_container()->get('request');
}
return $request; return $request;
} }
......
...@@ -358,6 +358,9 @@ function drupal_match_path($path, $patterns) { ...@@ -358,6 +358,9 @@ function drupal_match_path($path, $patterns) {
* @see request_path() * @see request_path()
*/ */
function current_path() { function current_path() {
if (drupal_container()->has('request')) {
return drupal_container()->get('request')->attributes->get('system_path');
}
return _current_path(); return _current_path();
} }
......
...@@ -69,9 +69,6 @@ public function onKernelRequestFrontPageResolve(GetResponseEvent $event) { ...@@ -69,9 +69,6 @@ public function onKernelRequestFrontPageResolve(GetResponseEvent $event) {
* The Event to process. * The Event to process.
*/ */
public function onKernelRequestLanguageResolve(GetResponseEvent $event) { public function onKernelRequestLanguageResolve(GetResponseEvent $event) {
$request = $event->getRequest();
$path = $this->extractPath($request);
// drupal_language_initialize() combines: // drupal_language_initialize() combines:
// - Determination of language from $request information (e.g., path). // - Determination of language from $request information (e.g., path).
// - Determination of language from other information (e.g., site default). // - Determination of language from other information (e.g., site default).
...@@ -81,9 +78,6 @@ public function onKernelRequestLanguageResolve(GetResponseEvent $event) { ...@@ -81,9 +78,6 @@ public function onKernelRequestLanguageResolve(GetResponseEvent $event) {
// prior to front page and alias resolution. When above is decoupled, also // prior to front page and alias resolution. When above is decoupled, also
// add 'langcode' (determined from $request only) to $request->attributes. // add 'langcode' (determined from $request only) to $request->attributes.
drupal_language_initialize(); drupal_language_initialize();
$path = _current_path();
$this->setPath($request, $path);
} }
/** /**
......
...@@ -225,7 +225,9 @@ function language_from_url($languages, $args = array()) { ...@@ -225,7 +225,9 @@ function language_from_url($languages, $args = array()) {
} }
list($language, $path) = language_url_split_prefix($current_path, $languages); list($language, $path) = language_url_split_prefix($current_path, $languages);
_current_path($path); if ($request) {
$request->attributes->set('system_path', $path);
}
if ($language !== FALSE) { if ($language !== FALSE) {
$language_url = $language->langcode; $language_url = $language->langcode;
} }
......
...@@ -499,7 +499,6 @@ function user_page() { ...@@ -499,7 +499,6 @@ function user_page() {
if ($user->uid) { if ($user->uid) {
// @todo: Cleaner sub request handling. // @todo: Cleaner sub request handling.
$subrequest = Request::create('/user/' . $user->uid, 'GET', request()->query->all(), request()->cookies->all(), array(), request()->server->all()); $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); return drupal_container()->get('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST);
} }
else { else {
......
...@@ -25,11 +25,6 @@ ...@@ -25,11 +25,6 @@
// Create a request object from the HTTPFoundation. // Create a request object from the HTTPFoundation.
$request = Request::createFromGlobals(); $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 // Bootstrap all of Drupal's subsystems, but do not initialize anything that
// depends on the fully resolved Drupal path, because path resolution happens // depends on the fully resolved Drupal path, because path resolution happens
// during the REQUEST event of the kernel. // during the REQUEST event of the kernel.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment