RequestContext

class RequestContext

Holds information about the current request.

This class implements a fluent interface.

Methods

__construct(string $baseUrl = '', string $method = 'GET', string $host = 'localhost', string $scheme = 'http', int $httpPort = 80, int $httpsPort = 443, string $path = '/', string $queryString = '')
$this fromRequest(Request $request)

Updates the RequestContext information based on a HttpFoundation Request.

string getBaseUrl()

Gets the base URL.

$this setBaseUrl(string $baseUrl)

Sets the base URL.

string getPathInfo()

Gets the path info.

$this setPathInfo(string $pathInfo)

Sets the path info.

string getMethod()

Gets the HTTP method.

$this setMethod(string $method)

Sets the HTTP method.

string getHost()

Gets the HTTP host.

$this setHost(string $host)

Sets the HTTP host.

string getScheme()

Gets the HTTP scheme.

$this setScheme(string $scheme)

Sets the HTTP scheme.

int getHttpPort()

Gets the HTTP port.

$this setHttpPort(int $httpPort)

Sets the HTTP port.

int getHttpsPort()

Gets the HTTPS port.

$this setHttpsPort(int $httpsPort)

Sets the HTTPS port.

string getQueryString()

Gets the query string.

$this setQueryString(string $queryString)

Sets the query string.

array getParameters()

Returns the parameters.

$this setParameters(array $parameters)

Sets the parameters.

mixed getParameter(string $name)

Gets a parameter value.

bool hasParameter(string $name)

Checks if a parameter value is set for the given parameter.

$this setParameter(string $name, mixed $parameter)

Sets a parameter value.

Details

__construct(string $baseUrl = '', string $method = 'GET', string $host = 'localhost', string $scheme = 'http', int $httpPort = 80, int $httpsPort = 443, string $path = '/', string $queryString = '')

Parameters

string $baseUrl
string $method
string $host
string $scheme
int $httpPort
int $httpsPort
string $path
string $queryString

$this fromRequest(Request $request)

Updates the RequestContext information based on a HttpFoundation Request.

Parameters

Request $request

Return Value

$this

string getBaseUrl()

Gets the base URL.

Return Value

string The base URL

$this setBaseUrl(string $baseUrl)

Sets the base URL.

Parameters

string $baseUrl The base URL

Return Value

$this

string getPathInfo()

Gets the path info.

Return Value

string The path info

$this setPathInfo(string $pathInfo)

Sets the path info.

Parameters

string $pathInfo The path info

Return Value

$this

string getMethod()

Gets the HTTP method.

The method is always an uppercased string.

Return Value

string The HTTP method

$this setMethod(string $method)

Sets the HTTP method.

Parameters

string $method The HTTP method

Return Value

$this

string getHost()

Gets the HTTP host.

The host is always lowercased because it must be treated case-insensitive.

Return Value

string The HTTP host

$this setHost(string $host)

Sets the HTTP host.

Parameters

string $host The HTTP host

Return Value

$this

string getScheme()

Gets the HTTP scheme.

Return Value

string The HTTP scheme

$this setScheme(string $scheme)

Sets the HTTP scheme.

Parameters

string $scheme The HTTP scheme

Return Value

$this

int getHttpPort()

Gets the HTTP port.

Return Value

int The HTTP port

$this setHttpPort(int $httpPort)

Sets the HTTP port.

Parameters

int $httpPort The HTTP port

Return Value

$this

int getHttpsPort()

Gets the HTTPS port.

Return Value

int The HTTPS port

$this setHttpsPort(int $httpsPort)

Sets the HTTPS port.

Parameters

int $httpsPort The HTTPS port

Return Value

$this

string getQueryString()

Gets the query string.

Return Value

string The query string without the "?"

$this setQueryString(string $queryString)

Sets the query string.

Parameters

string $queryString The query string (after "?")

Return Value

$this

array getParameters()

Returns the parameters.

Return Value

array The parameters

$this setParameters(array $parameters)

Sets the parameters.

Parameters

array $parameters The parameters

Return Value

$this

mixed getParameter(string $name)

Gets a parameter value.

Parameters

string $name A parameter name

Return Value

mixed The parameter value or null if nonexistent

bool hasParameter(string $name)

Checks if a parameter value is set for the given parameter.

Parameters

string $name A parameter name

Return Value

bool True if the parameter value is set, false otherwise

$this setParameter(string $name, mixed $parameter)

Sets a parameter value.

Parameters

string $name A parameter name
mixed $parameter The parameter value

Return Value

$this

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/4.0/Symfony/Component/Routing/RequestContext.html