MediaWiki  master
MediaWiki\Rest\RequestFromGlobals Class Reference

This is a request class that gets data directly from the superglobals and other global PHP state, notably php://input. More...

Inheritance diagram for MediaWiki\Rest\RequestFromGlobals:
Collaboration diagram for MediaWiki\Rest\RequestFromGlobals:

Public Member Functions

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

Protected Member Functions

 initHeaders ()
 
- Protected Member Functions inherited from MediaWiki\Rest\RequestBase
 __construct ( $cookiePrefix)
 
 initHeaders ()
 Override this in the implementation class if lazy initialisation of header values is desired. More...
 
 setHeaders ( $headers)
 Erase any existing headers and replace them with the specified header lines. More...
 

Private Attributes

 $protocol
 
 $uploadedFiles
 
 $uri
 

Detailed Description

This is a request class that gets data directly from the superglobals and other global PHP state, notably php://input.

Definition at line 15 of file RequestFromGlobals.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Rest\RequestFromGlobals::__construct (   $params = [])
Parameters
array$paramsAssociative array of parameters:
  • cookiePrefix: The prefix for cookie names used by getCookie()

Definition at line 24 of file RequestFromGlobals.php.

Member Function Documentation

◆ getBody()

MediaWiki\Rest\RequestFromGlobals::getBody ( )

Gets the body of the message.

Returns
StreamInterface Returns the body as a stream.

Implements MediaWiki\Rest\RequestInterface.

Definition at line 73 of file RequestFromGlobals.php.

◆ getCookieParams()

MediaWiki\Rest\RequestFromGlobals::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

Implements MediaWiki\Rest\RequestInterface.

Definition at line 83 of file RequestFromGlobals.php.

◆ getMethod()

MediaWiki\Rest\RequestFromGlobals::getMethod ( )

Retrieves the HTTP method of the request.

Returns
string Returns the request method.

Implements MediaWiki\Rest\RequestInterface.

Definition at line 30 of file RequestFromGlobals.php.

◆ getPostParams()

MediaWiki\Rest\RequestFromGlobals::getPostParams ( )

Retrieve POST form parameters.

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

Returns
array The deserialized POST parameters

Implements MediaWiki\Rest\RequestInterface.

Definition at line 98 of file RequestFromGlobals.php.

◆ getProtocolVersion()

MediaWiki\Rest\RequestFromGlobals::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.

Implements MediaWiki\Rest\RequestInterface.

Definition at line 43 of file RequestFromGlobals.php.

References MediaWiki\Rest\RequestFromGlobals\$protocol.

◆ getQueryParams()

MediaWiki\Rest\RequestFromGlobals::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

Implements MediaWiki\Rest\RequestInterface.

Definition at line 87 of file RequestFromGlobals.php.

◆ getServerParams()

MediaWiki\Rest\RequestFromGlobals::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

Implements MediaWiki\Rest\RequestInterface.

Definition at line 79 of file RequestFromGlobals.php.

◆ getUploadedFiles()

MediaWiki\Rest\RequestFromGlobals::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.

Implements MediaWiki\Rest\RequestInterface.

Definition at line 91 of file RequestFromGlobals.php.

References MediaWiki\Rest\RequestFromGlobals\$uploadedFiles.

◆ getUri()

MediaWiki\Rest\RequestFromGlobals::getUri ( )

Retrieves the URI instance.

This method MUST return a UriInterface instance.

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

Implements MediaWiki\Rest\RequestInterface.

Definition at line 34 of file RequestFromGlobals.php.

References MediaWiki\Rest\RequestFromGlobals\$uri, and WebRequest\getGlobalRequestURL().

◆ initHeaders()

MediaWiki\Rest\RequestFromGlobals::initHeaders ( )
protected

Definition at line 56 of file RequestFromGlobals.php.

References MediaWiki\Rest\RequestBase\setHeaders().

Member Data Documentation

◆ $protocol

MediaWiki\Rest\RequestFromGlobals::$protocol
private

◆ $uploadedFiles

MediaWiki\Rest\RequestFromGlobals::$uploadedFiles
private

◆ $uri

MediaWiki\Rest\RequestFromGlobals::$uri
private

Definition at line 16 of file RequestFromGlobals.php.

Referenced by MediaWiki\Rest\RequestFromGlobals\getUri().


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