In order to depend on using the Request object to determine caching, we need to ensure that everything uses it, rather than raw PHP variables for $_SERVER, $_REQUEST, $_GET, $_POST.
Conversion Guide
Remaining tasks: One last patch to remove all last $_GET, $_POST, $_COOKIE, $_REQUEST references. (Ignore $_SESSION for now, as it's being addressed elsewhere.)
Here are the methods on the Request object that map to PHP variables.
- $request->query The GET parameters
- $request->request The POST parameters
- $request->attributes The request attributes (parameters parsed from the PATH_INFO, ...)
- $request->cookies The COOKIE parameters
- $request->files The FILES parameters
- $request->server The SERVER parameters
See the Symfony documentation for an overview or a full list of convenience methods
- http://symfony.com/doc/current/components/http_foundation/introduction.html
- http://api.symfony.com/2.2/Symfony/Component/HttpFoundation/Request.html
To get the request object:
- If it is a route controller method, you can add a Request parameter as the last param in the method signature, and it will magically be passed in
- If you are in a new PSR-0, namespaced class, use
\Drupal::request()
(with a leading backslash) - If you are in old-skool functional land (e.g. includes) use
Drupal::request()
(without a leading backslash)
Sub-issues
..