Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
27ac97ef
Commit
27ac97ef
authored
Apr 07, 2013
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1957156
by Crell, rootatwc: Add a request() method to \Drupal.
parent
2e3c6842
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
core/lib/Drupal.php
core/lib/Drupal.php
+26
-0
No files found.
core/lib/Drupal.php
View file @
27ac97ef
...
...
@@ -121,6 +121,32 @@ public static function service($id) {
return
static
::
$container
->
get
(
$id
);
}
/**
* Retrieves the currently active request object.
*
* Note: The use of this wrapper in particular is especially discourged. Most
* code should not need to access the request directly. Doing so means it
* will only function when handling an HTTP request, and will require special
* modification or wrapping when run from a command line tool, from certain
* queue processors, or from automated tests.
*
* If code must access the request, it is considerably better to register
* an object with the Service Container and give it a setRequest() method
* that is configured to run when the service is created. That way, the
* correct request object can always be provided by the container and the
* service can still be unit tested.
*
* If this method must be used, never save the request object that is
* returned. Doing so may lead to inconsistencies as the request object is
* volatile and may change at various times, such as during a subrequest.
*
* @return \Symfony\Component\HttpFoundation\Request
* The currently active request object.
*/
public
static
function
request
()
{
return
static
::
$container
->
get
(
'request'
);
}
/**
* Returns the current primary database.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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