PHP Class Neos\Flow\Http\Request

Inheritance: extends AbstractMessage
Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Свойство Type Description
$arguments array
$attributes array PSR-7
$baseUri Uri
$inputStreamUri string URI for the "input" stream wrapper which can be modified for testing purposes
$method string
$server array Data similar to that which is typically provided by $_SERVER
$uri Uri

Méthodes publiques

Méthode Description
__clone ( ) Creates a deep clone
__construct ( array $get, array $post, array $files, array $server ) Constructs a new Request object based on the given environment data.
__toString ( ) : string Cast the request to a string: return the content part of this response
create ( Uri $uri, string $method = 'GET', array $arguments = [], array $files = [], array $server = [] ) : Request Creates a new Request object from the given data.
createActionRequest ( ) : ActionRequest Creates a new Action Request request as a sub request to this HTTP request.
createFromEnvironment ( ) : Request Considers the environment information found in PHP's superglobals and Flow's environment configuration and creates a new instance of this Request class matching that data.
getAcceptedMediaTypes ( ) : array Returns an list of IANA media types defined in the Accept header.
getArgument ( string $name ) : mixed Returns the value of the specified GET / POST / PUT argument.
getArguments ( ) : array Returns the unified arguments of this request.
getAttribute ( string $name, mixed $default = null ) : mixed PSR-7
getAttributes ( ) : mixed[] PSR-7
getBaseUri ( ) : Uri Returns the detected base URI
getClientIpAddress ( ) : string Returns the best guess of the client's IP address.
getContent ( boolean $asResource = false ) : string | resource Returns the content of the request body
getMethod ( ) : string Returns the request method
getNegotiatedMediaType ( array $supportedMediaTypes, boolean $trim = true ) : string Returns the best fitting IANA media type after applying the content negotiation rules on a possible Accept header.
getPort ( ) : integer Returns the port used for this request
getRelativePath ( ) : string Returns the request's path relative to the $baseUri
getRequestLine ( ) : string Return the Request-Line of this Request Message, consisting of the method, the uri and the HTTP version Would be, for example, "GET /foo?bar=baz HTTP/1.1" Note that the URI part is, at the moment, only possible in the form "abs_path" since the actual requestUri of the Request cannot be determined during the creation of the Request.
getScriptRequestPath ( ) : string Returns the relative path (ie. relative to the web root) to the script as it was accessed through the web server.
getScriptRequestPathAndFilename ( ) : string Returns the relative path (ie. relative to the web root) and name of the script as it was accessed through the web server.
getServerParams ( ) : array PSR-7
getStartLine ( ) : string Returns the first line of this Request Message, which is the Request-Line in this case
getUri ( ) : Uri Returns the request URI
hasArgument ( string $name ) : boolean Checks if an argument of the given name exists in this request.
isMethodSafe ( ) : boolean Tells if the request method is "safe", that is, it is expected to not take any other action than retrieval. This should the case with "GET" and "HEAD" requests.
isSecure ( ) : boolean Indicates if this request has been received through a secure channel.
mediaRangeMatches ( string $mediaRange, string $mediaType ) : boolean Checks if the given media range and the media type match.
parseContentNegotiationQualityValues ( string $rawValues ) : array Parses a RFC 2616 content negotiation header field by evaluating the Quality Values and splitting the options into an array list, ordered by user preference.
parseMediaType ( string $rawMediaType ) : array Parses a RFC 2616 Media Type and returns its parts in an associative array.
renderHeaders ( ) : string Renders the HTTP headers - including the status header - of this request
setBaseUri ( Uri $baseUri )
setContent ( string | resource $content ) : void Explicitly sets the content of the request body
setMethod ( string $method ) : void Sets the request method
trimMediaType ( string $rawMediaType ) : string Strips off any parameters from the given media type and returns just the type and subtype in the format "type/subtype".
withAttribute ( string $name, mixed $value ) : self PSR-7
withoutAttribute ( string $name ) : self PSR-7

Méthodes protégées

Méthode Description
buildUnifiedArguments ( array $getArguments, array $postArguments, array $uploadArguments ) : array Takes the raw GET & POST arguments and maps them into the request object.
calculateFieldPaths ( array $structure, string $firstLevelFieldName = null ) : array Returns and array of all possibles "field paths" for the given array.
detectBaseUri ( ) : void Tries to detect the base URI of request.
setAttribute ( string $name, mixed $value )
unsetAttribute ( string $name )
untangleFilesArray ( array $convolutedFiles ) : array Transforms the convoluted _FILES superglobal into a manageable form.

Method Details

__clone() public méthode

Creates a deep clone
public __clone ( )

__construct() public méthode

Constructs a new Request object based on the given environment data.
See also: create()
See also: createFromEnvironment()
public __construct ( array $get, array $post, array $files, array $server )
$get array Data similar to that which is typically provided by $_GET
$post array Data similar to that which is typically provided by $_POST
$files array Data similar to that which is typically provided by $_FILES
$server array Data similar to that which is typically provided by $_SERVER

__toString() public méthode

Cast the request to a string: return the content part of this response
public __toString ( ) : string
Résultat string The same as getContent()

buildUnifiedArguments() protected méthode

Afterwards all mapped arguments can be retrieved by the getArgument(s) method, no matter if they have been GET, POST or PUT arguments before.
protected buildUnifiedArguments ( array $getArguments, array $postArguments, array $uploadArguments ) : array
$getArguments array Arguments as found in $_GET
$postArguments array Arguments as found in $_POST
$uploadArguments array Arguments as found in $_FILES
Résultat array the unified arguments

calculateFieldPaths() protected méthode

Returns and array of all possibles "field paths" for the given array.
protected calculateFieldPaths ( array $structure, string $firstLevelFieldName = null ) : array
$structure array The array to walk through
$firstLevelFieldName string
Résultat array An array of paths (as strings) in the format "key1/key2/key3" ...

create() public static méthode

Creates a new Request object from the given data.
public static create ( Uri $uri, string $method = 'GET', array $arguments = [], array $files = [], array $server = [] ) : Request
$uri Uri The request URI
$method string Request method, for example "GET"
$arguments array Arguments to send in the request body
$files array
$server array
Résultat Request

createActionRequest() public méthode

Maps the arguments of this request to the new Action Request.
Deprecation: since Flow 2.3. Create the ActionRequest manually instead: $actionRequest = new ActionRequest($httpRequest)
public createActionRequest ( ) : ActionRequest
Résultat Neos\Flow\Mvc\ActionRequest

createFromEnvironment() public static méthode

Considers the environment information found in PHP's superglobals and Flow's environment configuration and creates a new instance of this Request class matching that data.
public static createFromEnvironment ( ) : Request
Résultat Request

detectBaseUri() protected méthode

Tries to detect the base URI of request.
protected detectBaseUri ( ) : void
Résultat void

getAcceptedMediaTypes() public méthode

The list is ordered by user preference, after evaluating the Quality Values specified in the header field value. First items in the list are the most preferred. If no Accept header is present, the media type representing "any" media type is returned.
public getAcceptedMediaTypes ( ) : array
Résultat array A list of media types and sub types

getArgument() public méthode

Returns the value of the specified GET / POST / PUT argument.
public getArgument ( string $name ) : mixed
$name string Name of the argument
Résultat mixed Value of the specified argument or NULL if it does not exist

getArguments() public méthode

GET, POST and PUT arguments, as well es uploaded files, are merged into a whole array of arguments.
public getArguments ( ) : array
Résultat array

getAttribute() public méthode

Retrieve a single derived request attribute. Retrieves a single derived request attribute as described in getAttributes(). If the attribute has not been previously set, returns the default value as provided. This method obviates the need for a hasAttribute() method, as it allows specifying a default value to return if the attribute is not found.
See also: getAttributes()
public getAttribute ( string $name, mixed $default = null ) : mixed
$name string The attribute name.
$default mixed Default value to return if the attribute does not exist.
Résultat mixed

getAttributes() public méthode

Retrieve attributes derived from the request. The request "attributes" may be used to allow injection of any parameters derived from the request: e.g., the results of path match operations; the results of decrypting cookies; the results of deserializing non-form-encoded message bodies; etc. Attributes will be application and request specific, and CAN be mutable.
public getAttributes ( ) : mixed[]
Résultat mixed[] Attributes derived from the request.

getBaseUri() public méthode

Returns the detected base URI
public getBaseUri ( ) : Uri
Résultat Uri

getClientIpAddress() public méthode

Note that, depending on the actual source used, IP addresses can be spoofed and may not be reliable. Although several kinds of proxy headers are taken into account, certain combinations of ISPs and proxies might still produce wrong results. Don't rely on the client IP address as the only security measure!
public getClientIpAddress ( ) : string
Résultat string The client's IP address

getContent() public méthode

If the request body has not been set with setContent() previously, this method will try to retrieve it from the input stream. If $asResource was set to TRUE, the stream resource will be returned instead of a string. If the content which has been set by setContent() originally was a stream resource, that resource will be returned, no matter if $asResource is set.
public getContent ( boolean $asResource = false ) : string | resource
$asResource boolean If set, the content is returned as a resource pointing to PHP's input stream
Résultat string | resource

getMethod() public méthode

Returns the request method
public getMethod ( ) : string
Résultat string The request method

getNegotiatedMediaType() public méthode

Returns the best fitting IANA media type after applying the content negotiation rules on a possible Accept header.
public getNegotiatedMediaType ( array $supportedMediaTypes, boolean $trim = true ) : string
$supportedMediaTypes array A list of media types which are supported by the application / controller
$trim boolean If TRUE, only the type/subtype of the media type is returned. If FALSE, the full original media type string is returned.
Résultat string The media type and sub type which matched, NULL if none matched

getPort() public méthode

Returns the port used for this request
public getPort ( ) : integer
Résultat integer

getRelativePath() public méthode

Returns the request's path relative to the $baseUri
public getRelativePath ( ) : string
Résultat string

getRequestLine() public méthode

Return the Request-Line of this Request Message, consisting of the method, the uri and the HTTP version Would be, for example, "GET /foo?bar=baz HTTP/1.1" Note that the URI part is, at the moment, only possible in the form "abs_path" since the actual requestUri of the Request cannot be determined during the creation of the Request.
See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1
public getRequestLine ( ) : string
Résultat string

getScriptRequestPath() public méthode

Returns the relative path (ie. relative to the web root) to the script as it was accessed through the web server.
public getScriptRequestPath ( ) : string
Résultat string Relative path to the PHP script as accessed through the web

getScriptRequestPathAndFilename() public méthode

Returns the relative path (ie. relative to the web root) and name of the script as it was accessed through the web server.
public getScriptRequestPathAndFilename ( ) : string
Résultat string Relative path and name of the PHP script as accessed through the web

getServerParams() public méthode

Retrieve server parameters. Retrieves data related to the incoming request environment, typically derived from PHP's $_SERVER superglobal. The data IS NOT REQUIRED to originate from $_SERVER.
public getServerParams ( ) : array
Résultat array

getStartLine() public méthode

Returns the first line of this Request Message, which is the Request-Line in this case
See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html chapter 4.1 "Message Types"
public getStartLine ( ) : string
Résultat string The Request-Line of this Request

getUri() public méthode

Returns the request URI
public getUri ( ) : Uri
Résultat Uri

hasArgument() public méthode

Applies to GET, POST and PUT arguments similarly.
public hasArgument ( string $name ) : boolean
$name string Name of the argument
Résultat boolean

isMethodSafe() public méthode

Tells if the request method is "safe", that is, it is expected to not take any other action than retrieval. This should the case with "GET" and "HEAD" requests.
public isMethodSafe ( ) : boolean
Résultat boolean

isSecure() public méthode

Indicates if this request has been received through a secure channel.
public isSecure ( ) : boolean
Résultat boolean

mediaRangeMatches() public static méthode

Checks if the given media range and the media type match.
See also: MediaTypes::mediaRangeMatches()
Deprecation: since Flow 2.1. Use \Neos\Utility\MediaTypes::mediaRangeMatches() instead
public static mediaRangeMatches ( string $mediaRange, string $mediaType ) : boolean
$mediaRange string The media range, for example "text/*"
$mediaType string The media type to match against, for example "text/html"
Résultat boolean TRUE if both match, FALSE if they don't match or either of them is invalid

parseContentNegotiationQualityValues() public static méthode

Parses a RFC 2616 content negotiation header field by evaluating the Quality Values and splitting the options into an array list, ordered by user preference.
public static parseContentNegotiationQualityValues ( string $rawValues ) : array
$rawValues string The raw Accept* Header field value
Résultat array The parsed list of field values, ordered by user preference

parseMediaType() public static méthode

Parses a RFC 2616 Media Type and returns its parts in an associative array.
See also: MediaTypes::parseMediaType()
Deprecation: since Flow 2.1. Use \Neos\Utility\MediaTypes::parseMediaType() instead
public static parseMediaType ( string $rawMediaType ) : array
$rawMediaType string The raw media type, for example "application/json; charset=UTF-8"
Résultat array An associative array with parsed information

renderHeaders() public méthode

Renders the HTTP headers - including the status header - of this request
public renderHeaders ( ) : string
Résultat string The HTTP headers, one per line, separated by \r\n as required by RFC 2616 sec 5

setAttribute() protected méthode

protected setAttribute ( string $name, mixed $value )
$name string The attribute name.
$value mixed The value of the attribute.

setBaseUri() public méthode

public setBaseUri ( Uri $baseUri )
$baseUri Uri

setContent() public méthode

In most cases, content is just a string representation of the request body. In order to reduce memory consumption for uploads and other big data, it is also possible to pass a stream resource. The easies way to convert a local file into a stream resource is probably: $resource = fopen('file://path/to/file', 'rb');
public setContent ( string | resource $content ) : void
$content string | resource The body content, for example arguments of a PUT request, or a stream resource
Résultat void

setMethod() public méthode

Sets the request method
public setMethod ( string $method ) : void
$method string The request method, for example "GET".
Résultat void

trimMediaType() public static méthode

Strips off any parameters from the given media type and returns just the type and subtype in the format "type/subtype".
See also: Neos\Utility\MediaTypes::trimMediaType()
Deprecation: since Flow 2.1. Use \Neos\Utility\MediaTypes::trimMediaType() instead
public static trimMediaType ( string $rawMediaType ) : string
$rawMediaType string The full media type, for example "application/json; charset=UTF-8"
Résultat string Just the type and subtype, for example "application/json"

unsetAttribute() protected méthode

protected unsetAttribute ( string $name )
$name string The attribute name.

untangleFilesArray() protected méthode

Transforms the convoluted _FILES superglobal into a manageable form.
protected untangleFilesArray ( array $convolutedFiles ) : array
$convolutedFiles array The _FILES superglobal
Résultat array Untangled files

withAttribute() public méthode

Return an instance with the specified derived request attribute. This method allows setting a single derived request attribute as described in getAttributes(). This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated attribute.
See also: getAttributes()
public withAttribute ( string $name, mixed $value ) : self
$name string The attribute name.
$value mixed The value of the attribute.
Résultat self

withoutAttribute() public méthode

Return an instance that removes the specified derived request attribute. This method allows removing a single derived request attribute as described in getAttributes(). This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that removes the attribute.
See also: getAttributes()
public withoutAttribute ( string $name ) : self
$name string The attribute name.
Résultat self

Property Details

$arguments protected_oe property

protected array $arguments
Résultat array

$attributes protected_oe property

PSR-7
protected array $attributes
Résultat array

$baseUri protected_oe property

protected Uri,Neos\Flow\Http $baseUri
Résultat Uri

$inputStreamUri protected_oe property

URI for the "input" stream wrapper which can be modified for testing purposes
protected string $inputStreamUri
Résultat string

$method protected_oe property

protected string $method
Résultat string

$server protected_oe property

Data similar to that which is typically provided by $_SERVER
protected array $server
Résultat array

$uri protected_oe property

protected Uri,Neos\Flow\Http $uri
Résultat Uri