Property | Type | Description | |
---|---|---|---|
$data | array | Data found in the HTTP request body, most often populated by $_POST and $_FILES. | |
$params | array | Params for request. | |
$persist | array | Route parameters that should persist when generating URLs in this request context. | |
$query | array | Key/value pairs found encoded in the request URL after '?', populated by $_GET. | |
$url | string | Current url of request. |
Property | Type | Description | |
---|---|---|---|
$_accept | array | Contains an array of content-types, sorted by quality (the priority which the browser requests each type). | |
$_autoConfig | array | Auto configuration properties. | |
$_base | string | Base path. | |
$_computed | array | Computed environment variables for the request. Retrieved with env(). | |
$_detectors | array | embed:lithium\tests\cases\action\RequestTest::testRequestTypeIsMobile(4-4) Custom detectors can be added using detect(). | |
$_env | array | Holds the server globals & environment variables. | |
$_locale | string | Holds the value of the current locale, set through the locale() method. | |
$_stream | resource | If POST, PUT or PATCH data is coming from an input stream (rather than $_POST), this specified where to read it from. |
Method | Description | |
---|---|---|
__construct ( array $config = [] ) : void | Constructor. Adds config values to the public properties when a new object is created, pulling request data from superglobals if globals is set to true. | |
__get ( string $name ) : mixed | Allows request parameters to be accessed as object properties, i.e. $this->request->action instead of $this->request->params['action']. | |
__isset ( string $name ) : boolean | Allows request parameters to be checked using short-hand notation. See the __get() method for more details. | |
accepts ( boolean | string $type = null ) : string | boolean | array | Returns information about the type of content that the client is requesting. | |
detect ( string $flag, mixed $detector = null ) : void | Creates a _detector_ used with Request::is(). A detector is a boolean check that is created to determine something about a request. | |
env ( string $key ) : string | Queries PHP's environment settings, and provides an abstraction for standardizing expected environment values across varying platforms, as well as specify custom environment flags. | |
get ( string $key ) : string | This method allows easy extraction of any request data using a prefixed key syntax. By passing keys in the form of 'prefix:key', it is possible to query different information of various different types, including GET and POST data, and server environment variables. The full list of prefixes is as follows: | |
is ( string $flag ) : boolean | Provides a simple syntax for making assertions about the properties of a request. | |
locale ( string $locale = null ) : string | Sets or returns the current locale string. For more information, see "Globalization" in the manual. | |
referer ( string $default = null, boolean $local = false ) : string | Gets the referring URL of this request. | |
to ( string $format, array $options = [] ) : mixed | Overrides lithium\net\http\Request::to() to provide the correct options for generating URLs. For information about this method, see the parent implementation. | |
type ( string $type = null ) : string | Sets/Gets the content type. If 'type' is null, the method will attempt to determine the type from the params, then from the environment setting |
Method | Description | |
---|---|---|
_base ( string $base = null ) : string | Find the base path of the current request. | |
_init ( ) | Initializes request object by setting up mobile detectors, determining method and populating the data property either by using i.e. form data or reading from STDIN in case binary data is streamed. Will merge any files posted in forms with parsed data. | |
_parseAccept ( ) : array | Parses the HTTP_ACCEPT information the requesting client sends, and converts that data to an array for consumption by the rest of the framework. | |
_parseFiles ( array $data ) : array | Normalizes the data from the $_FILES superglobal. | |
_url ( $url = null ) : string | Extract the url from REQUEST_URI && PHP_SELF environment variables. |
public __construct ( array $config = [] ) : void | ||
$config | array | The available configuration options are the following. Further options are inherited from the parent classes. - `'base'` _string_: Defaults to `null`. - `'url'` _string_: Defaults to `null`. - `'data'` _array_: Additional data to use when initializing the request. Defaults to `array()`. - `'stream'` _resource_: Stream to read from in order to get the message body when method is POST, PUT or PATCH and data is empty. When not provided `php://input` will be used for reading. - `'env'` _array_: Defaults to `array()`. - `'globals'` _boolean_: Use global variables for populating the request's environment and data; defaults to `true`. |
return | void |
protected _init ( ) |
protected _parseAccept ( ) : array | ||
return | array | All the types of content the client can accept. |
protected _parseFiles ( array $data ) : array | ||
$data | array | Data as formatted in the `$_FILES` superglobal. |
return | array | Normalized data. |
public accepts ( boolean | string $type = null ) : string | boolean | array | ||
$type | boolean | string | Optionally a type name i.e. `'json'` or `true`. 1. If not specified, returns the media type name that the client prefers, using a potentially set `type` param, then content negotiation and that fails, ultimately falling back and returning the string `'html'`. 2. If a media type name (string) is passed, returns `true` or `false`, indicating whether or not that type is accepted by the client at all. 3. If `true`, returns the raw content types from the `Accept` header, parsed into an array and sorted by client preference. |
return | string | boolean | array | Returns a type name (i.e. 'json'`) or a boolean or an array, depending on the value of `$type`. |
public detect ( string $flag, mixed $detector = null ) : void | ||
$flag | string | The name of the detector check. Used in subsequent calls to `Request::is()`. |
$detector | mixed | Detectors can be specified in four different ways: - The name of an HTTP header or environment variable. If a string, calling the detector will check that the header or environment variable exists and is set to a non-empty value. - A two-element array containing a header/environment variable name, and a value to match against. The second element of the array must be an exact match to the header or variable value. - A two-element array containing a header/environment variable name, and a regular expression that matches against the value, as in the example above. - A closure which accepts an instance of the `Request` object and returns a boolean value. |
return | void |
public get ( string $key ) : string | ||
$key | string | A prefixed key indicating what part of the request data the requested value should come from, and the name of the value to retrieve, in lower case. |
return | string | Returns the value of a GET, POST, routing or environment variable, or an HTTP header or method name. |
public is ( string $flag ) : boolean | ||
$flag | string | The name of the flag to check, which should be the name of a valid detector (that is either built-in or defined with `detect()`). |
return | boolean | Returns `true` if the detector check succeeds (see the details for the built-in detectors above, or `detect()`), otherwise `false`. |
protected array $_accept | ||
return | array |
protected array $_autoConfig | ||
return | array |
protected array $_computed | ||
return | array |
protected array $_detectors | ||
return | array |
protected array $_env | ||
return | array |
protected string $_locale | ||
return | string |
protected resource $_stream | ||
return | resource |
public array $data | ||
return | array |
public array $persist | ||
return | array |
public array $query | ||
return | array |