PHP 클래스 lithium\action\Request

또한 보기: lithium\action\Dispatcher
또한 보기: lithium\action\Controller
또한 보기: lithium\net\http\Router
또한 보기: lithium\net\http\Route
또한 보기: lithium\action\Request::__get()
상속: extends lithium\net\http\Request
파일 보기 프로젝트 열기: unionofrad/lithium 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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.

보호된 프로퍼티들

프로퍼티 타입 설명
$_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.

공개 메소드들

메소드 설명
__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

보호된 메소드들

메소드 설명
_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.

메소드 상세

__construct() 공개 메소드

Normalizes casing of request headers.
또한 보기: lithium\net\http\Request::__construct()
또한 보기: lithium\net\http\Message::__construct()
또한 보기: lithium\net\Message::__construct()
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`.
리턴 void

__get() 공개 메소드

Allows request parameters to be accessed as object properties, i.e. $this->request->action instead of $this->request->params['action'].
또한 보기: lithium\action\Request::$params
public __get ( string $name ) : mixed
$name string The property name/parameter key to return.
리턴 mixed Returns the value of `$params[$name]` if it is set, otherwise returns null.

__isset() 공개 메소드

Allows request parameters to be checked using short-hand notation. See the __get() method for more details.
또한 보기: lithium\action\Request::__get()
public __isset ( string $name ) : boolean
$name string The name of the request parameter to check.
리턴 boolean Returns true if the key in `$name` is set in the `$params` array, otherwise `false`.

_base() 보호된 메소드

Find the base path of the current request.
protected _base ( string $base = null ) : string
$base string The base path. If `null`, `'PHP_SELF'` will be used instead.
리턴 string

_init() 보호된 메소드

Note that only beginning with PHP 5.6 STDIN can be opened/read and closed more than once.
또한 보기: lithium\action\Request::_parseFiles()
protected _init ( )

_parseAccept() 보호된 메소드

Parses the HTTP_ACCEPT information the requesting client sends, and converts that data to an array for consumption by the rest of the framework.
protected _parseAccept ( ) : array
리턴 array All the types of content the client can accept.

_parseFiles() 보호된 메소드

Normalizes the data from the $_FILES superglobal.
protected _parseFiles ( array $data ) : array
$data array Data as formatted in the `$_FILES` superglobal.
리턴 array Normalized data.

_url() 보호된 메소드

Extract the url from REQUEST_URI && PHP_SELF environment variables.
protected _url ( $url = null ) : string
리턴 string

accepts() 공개 메소드

This method may work different then you might think. This is a _convenience_ method working exclusively with short type names it knows about. Only those types will be matched. You can tell this method about more types via Media::type(). Note: In case negotiation fails, 'html' is used as a fallback type.
또한 보기: lithium\net\http\Media::negotiate()
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.
리턴 string | boolean | array Returns a type name (i.e. 'json'`) or a boolean or an array, depending on the value of `$type`.

detect() 공개 메소드

A detector check can be either an exact string match or a regular expression match against a header or environment variable. A detector check can also be a closure that accepts the Request object instance as a parameter. For example, to detect whether a request is from an iPhone, you can do the following: embed:lithium\tests\cases\action\RequestTest::testDetect(11-12)
또한 보기: lithium\action\Request::is()
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.
리턴 void

env() 공개 메소드

Defines an artificial 'PLATFORM' environment variable as either 'IIS', 'CGI' or null to allow checking for the SAPI in a normalized way.
public env ( string $key ) : string
$key string The environment variable required.
리턴 string The requested variables value.

get() 공개 메소드

- 'data': Retrieves values from POST data. - 'params': Retrieves query parameters returned from the routing system. - 'query': Retrieves values from GET data. - 'env': Retrieves values from the server or environment, such as 'env:https', or custom environment values, like 'env:base'. See the env() method for more info. - 'http': Retrieves header values (i.e. 'http:accept'), or the HTTP request method (i.e. 'http:method'). This method is used in several different places in the framework in order to provide the ability to act conditionally on different aspects of the request. See Media::type() (the section on content negotiation) and the routing system for more information. _Note_: All keys should be _lower-cased_, even when getting HTTP headers.
또한 보기: lithium\action\Request::env()
또한 보기: lithium\net\http\Media::type()
또한 보기: lithium\net\http\Router
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.
리턴 string Returns the value of a GET, POST, routing or environment variable, or an HTTP header or method name.

is() 공개 메소드

By default, the Request object is configured with several different types of assertions, which are individually known as _detectors_. Detectors are invoked by calling the is() and passing the name of the detector flag, i.e. $request->is(''), which returns true or false, depending on whether or not the the properties (usually headers or data) contained in the request match the detector. The default detectors include the following: - 'mobile': Uses a regular expression to match common mobile browser user agents. - 'ajax': Checks to see if the X-Requested-With header is present, and matches the value 'XMLHttpRequest'. - 'flash': Checks to see if the user agent is 'Shockwave Flash'. - 'ssl': Verifies that the request is SSL-secured. - 'get' / 'post' / 'put' / 'delete' / 'head' / 'options': Checks that the HTTP request method matches the one specified. In addition to the above, this method also accepts media type names (see Media::type()) to make assertions against the format of the request body (for POST or PUT requests), i.e. $request->is('json'). This will return true if the client has made a POST request with JSON data. For information about adding custom detectors or overriding the ones in the core, see the detect() method. While these detectors are useful in controllers or other similar contexts, they're also useful when performing _content negotiation_, which is the process of modifying the response format to suit the client (see the 'conditions' field of the $options parameter in Media::type()).
또한 보기: lithium\action\Request::detect()
또한 보기: lithium\net\http\Media::type()
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()`).
리턴 boolean Returns `true` if the detector check succeeds (see the details for the built-in detectors above, or `detect()`), otherwise `false`.

locale() 공개 메소드

Sets or returns the current locale string. For more information, see "Globalization" in the manual.
public locale ( string $locale = null ) : string
$locale string An optional locale string like `'en'`, `'en_US'` or `'de_DE'`. If specified, will overwrite the existing locale.
리턴 string Returns the currently set locale string.

referer() 공개 메소드

Gets the referring URL of this request.
public referer ( string $default = null, boolean $local = false ) : string
$default string Default URL to use if HTTP_REFERER cannot be read from headers.
$local boolean If true, restrict referring URLs to local server.
리턴 string Referring URL.

to() 공개 메소드

Overrides lithium\net\http\Request::to() to provide the correct options for generating URLs. For information about this method, see the parent implementation.
또한 보기: lithium\net\http\Request::to()
public to ( string $format, array $options = [] ) : mixed
$format string The format to convert to.
$options array Override options.
리턴 mixed The return value type depends on `$format`.

type() 공개 메소드

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
public type ( string $type = null ) : string
$type string a full content type i.e. `'application/json'` or simple name `'json'`
리턴 string A simple content type name, i.e. `'html'`, `'xml'`, `'json'`, etc., depending on the content type of the request.

프로퍼티 상세

$_accept 보호되어 있는 프로퍼티

Contains an array of content-types, sorted by quality (the priority which the browser requests each type).
protected array $_accept
리턴 array

$_autoConfig 보호되어 있는 프로퍼티

Auto configuration properties.
protected array $_autoConfig
리턴 array

$_base 보호되어 있는 프로퍼티

Base path.
protected string $_base
리턴 string

$_computed 보호되어 있는 프로퍼티

Computed environment variables for the request. Retrieved with env().
또한 보기: lithium\action\Request::env()
protected array $_computed
리턴 array

$_detectors 보호되어 있는 프로퍼티

embed:lithium\tests\cases\action\RequestTest::testRequestTypeIsMobile(4-4) Custom detectors can be added using detect().
또한 보기: lithium\action\Request::is()
또한 보기: lithium\action\Request::detect()
protected array $_detectors
리턴 array

$_env 보호되어 있는 프로퍼티

Holds the server globals & environment variables.
protected array $_env
리턴 array

$_locale 보호되어 있는 프로퍼티

Holds the value of the current locale, set through the locale() method.
protected string $_locale
리턴 string

$_stream 보호되어 있는 프로퍼티

If POST, PUT or PATCH data is coming from an input stream (rather than $_POST), this specified where to read it from.
또한 보기: lithium\action\Request::_init()
protected resource $_stream
리턴 resource

$data 공개적으로 프로퍼티

Data found in the HTTP request body, most often populated by $_POST and $_FILES.
public array $data
리턴 array

$params 공개적으로 프로퍼티

Params for request.
public array $params
리턴 array

$persist 공개적으로 프로퍼티

Route parameters that should persist when generating URLs in this request context.
public array $persist
리턴 array

$query 공개적으로 프로퍼티

Key/value pairs found encoded in the request URL after '?', populated by $_GET.
public array $query
리턴 array

$url 공개적으로 프로퍼티

Current url of request.
public string $url
리턴 string