MediaWiki REL1_34
MediaWiki\Rest\RequestInterface Interface Reference

A request interface similar to PSR-7's ServerRequestInterface. More...

Inheritance diagram for MediaWiki\Rest\RequestInterface:

Public Member Functions

 getBody ()
 Gets the body of the message.
 
 getCookie ( $name, $default=null)
 Add the cookie prefix to a specified cookie name and get the value of the resulting prefixed cookie.
 
 getCookieParams ()
 Retrieve cookies.
 
 getCookiePrefix ()
 Get the current cookie prefix.
 
 getHeader ( $name)
 Retrieves a message header value by the given case-insensitive name.
 
 getHeaderLine ( $name)
 Retrieves a comma-separated string of the values for a single header.
 
 getHeaders ()
 Retrieves all message header values.
 
 getMethod ()
 Retrieves the HTTP method of the request.
 
 getPathParam ( $name)
 Retrieve a single path parameter.
 
 getPathParams ()
 Get the parameters derived from the path template match.
 
 getPostParams ()
 Retrieve POST form parameters.
 
 getProtocolVersion ()
 Retrieves the HTTP protocol version as a string.
 
 getQueryParams ()
 Retrieve query string arguments.
 
 getServerParams ()
 Retrieve server parameters.
 
 getUploadedFiles ()
 Retrieve normalized file upload data.
 
 getUri ()
 Retrieves the URI instance.
 
 hasHeader ( $name)
 Checks if a header exists by the given case-insensitive name.
 
 setPathParams ( $params)
 Erase all path parameters from the object and set the parameter array to the one specified.
 

Detailed Description

A request interface similar to PSR-7's ServerRequestInterface.

Definition at line 39 of file RequestInterface.php.

Member Function Documentation

◆ getBody()

MediaWiki\Rest\RequestInterface::getBody ( )

Gets the body of the message.

Returns
StreamInterface Returns the body as a stream.

Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.

Referenced by MediaWiki\Rest\Validator\Validator\validateBody().

◆ getCookie()

MediaWiki\Rest\RequestInterface::getCookie ( $name,
$default = null )

Add the cookie prefix to a specified cookie name and get the value of the resulting prefixed cookie.

If the cookie does not exist, $default is returned.

Parameters
string$name
mixed | null$default
Returns
mixed The cookie value as a string, or $default

Implemented in MediaWiki\Rest\RequestBase.

◆ getCookieParams()

MediaWiki\Rest\RequestInterface::getCookieParams ( )

Retrieve cookies.

Retrieves cookies sent by the client to the server.

The data MUST be compatible with the structure of the $_COOKIE superglobal.

Returns
array

Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.

Referenced by MediaWiki\Rest\RequestBase\getCookie().

◆ getCookiePrefix()

MediaWiki\Rest\RequestInterface::getCookiePrefix ( )

Get the current cookie prefix.

Returns
string

Implemented in MediaWiki\Rest\RequestBase.

◆ getHeader()

MediaWiki\Rest\RequestInterface::getHeader ( $name)

Retrieves a message header value by the given case-insensitive name.

This method returns an array of all the header values of the given case-insensitive header name.

If the header does not appear in the message, this method MUST return an empty array.

A single header value may be a string containing a comma-separated list. Lists will not necessarily be split into arrays. See the comment on HeaderContainer::convertToListAndString().

Parameters
string$nameCase-insensitive header field name.
Returns
string[] An array of string values as provided for the given header. If the header does not appear in the message, this method MUST return an empty array.

Implemented in MediaWiki\Rest\RequestBase.

◆ getHeaderLine()

MediaWiki\Rest\RequestInterface::getHeaderLine ( $name)

Retrieves a comma-separated string of the values for a single header.

This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma.

NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating.

If the header does not appear in the message, this method MUST return an empty string.

Parameters
string$nameCase-insensitive header field name.
Returns
string A string of values as provided for the given header concatenated together using a comma. If the header does not appear in the message, this method MUST return an empty string.

Implemented in MediaWiki\Rest\RequestBase.

Referenced by MediaWiki\Rest\Validator\Validator\validateBody().

◆ getHeaders()

MediaWiki\Rest\RequestInterface::getHeaders ( )

Retrieves all message header values.

The keys represent the header name as it will be sent over the wire, and each value is an array of strings associated with the header.

// Represent the headers as a string
foreach ($message->getHeaders() as $name => $values) {
    echo $name . ": " . implode(", ", $values);
}

// Emit headers iteratively:
foreach ($message->getHeaders() as $name => $values) {
    foreach ($values as $value) {
        header(sprintf('%s: %s', $name, $value), false);
    }
}

While header names are not case-sensitive, getHeaders() will preserve the exact case in which headers were originally specified.

A single header value may be a string containing a comma-separated list. Lists will not necessarily be split into arrays. See the comment on HeaderContainer::convertToListAndString().

Returns
string[][] Returns an associative array of the message's headers. Each key MUST be a header name, and each value MUST be an array of strings for that header.

Implemented in MediaWiki\Rest\RequestBase.

◆ getMethod()

MediaWiki\Rest\RequestInterface::getMethod ( )

Retrieves the HTTP method of the request.

Returns
string Returns the request method.

Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.

Referenced by MediaWiki\Rest\Router\execute(), and MediaWiki\Rest\Validator\Validator\validateBody().

◆ getPathParam()

MediaWiki\Rest\RequestInterface::getPathParam ( $name)

Retrieve a single path parameter.

Retrieves a single path parameter as described in getPathParams(). If the attribute has not been previously set, returns null.

See also
getPathParams()
Parameters
string$nameThe parameter name.
Returns
string|null

Implemented in MediaWiki\Rest\RequestBase.

◆ getPathParams()

MediaWiki\Rest\RequestInterface::getPathParams ( )

Get the parameters derived from the path template match.

Returns
string[]

Implemented in MediaWiki\Rest\RequestBase.

◆ getPostParams()

MediaWiki\Rest\RequestInterface::getPostParams ( )

Retrieve POST form parameters.

This will return an array of parameters in the format of $_POST.

Returns
array The deserialized POST parameters

Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.

◆ getProtocolVersion()

MediaWiki\Rest\RequestInterface::getProtocolVersion ( )

Retrieves the HTTP protocol version as a string.

The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").

Returns
string HTTP protocol version.

Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.

◆ getQueryParams()

MediaWiki\Rest\RequestInterface::getQueryParams ( )

Retrieve query string arguments.

Retrieves the deserialized query string arguments, if any.

Note: the query params might not be in sync with the URI or server params. If you need to ensure you are only getting the original values, you may need to parse the query string from getUri()->getQuery() or from the QUERY_STRING server param.

Returns
array

Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.

◆ getServerParams()

MediaWiki\Rest\RequestInterface::getServerParams ( )

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.

Returns
array

Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.

◆ getUploadedFiles()

MediaWiki\Rest\RequestInterface::getUploadedFiles ( )

Retrieve normalized file upload data.

This method returns upload metadata in a normalized tree, with each leaf an instance of Psr\Http\Message\UploadedFileInterface.

Returns
array An array tree of UploadedFileInterface instances; an empty array MUST be returned if no data is present.

Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.

◆ getUri()

MediaWiki\Rest\RequestInterface::getUri ( )

Retrieves the URI instance.

This method MUST return a UriInterface instance.

UriInterface Returns a UriInterface instance representing the URI of the request.

Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.

Referenced by MediaWiki\Rest\Router\execute().

◆ hasHeader()

MediaWiki\Rest\RequestInterface::hasHeader ( $name)

Checks if a header exists by the given case-insensitive name.

Parameters
string$nameCase-insensitive header field name.
Returns
bool Returns true if any header names match the given header name using a case-insensitive string comparison. Returns false if no matching header name is found in the message.

Implemented in MediaWiki\Rest\RequestBase.

◆ setPathParams()

MediaWiki\Rest\RequestInterface::setPathParams ( $params)

Erase all path parameters from the object and set the parameter array to the one specified.

Parameters
string[]$params

Implemented in MediaWiki\Rest\RequestBase.

Referenced by MediaWiki\Rest\Router\execute().


The documentation for this interface was generated from the following file: