Symfony API
Class

Symfony\Component\Routing\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 = '')

Constructor.

RequestContext fromRequest(Request $request)

Updates the RequestContext information based on a HttpFoundation Request.

string getBaseUrl()

Gets the base URL.

RequestContext setBaseUrl(string $baseUrl)

Sets the base URL.

string getPathInfo()

Gets the path info.

RequestContext setPathInfo(string $pathInfo)

Sets the path info.

string getMethod()

Gets the HTTP method.

RequestContext setMethod(string $method)

Sets the HTTP method.

string getHost()

Gets the HTTP host.

RequestContext setHost(string $host)

Sets the HTTP host.

string getScheme()

Gets the HTTP scheme.

RequestContext setScheme(string $scheme)

Sets the HTTP scheme.

int getHttpPort()

Gets the HTTP port.

RequestContext setHttpPort(int $httpPort)

Sets the HTTP port.

int getHttpsPort()

Gets the HTTPS port.

RequestContext setHttpsPort(int $httpsPort)

Sets the HTTPS port.

string getQueryString()

Gets the query string.

RequestContext setQueryString(string $queryString)

Sets the query string.

array getParameters()

Returns the parameters.

RequestContext 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.

RequestContext setParameter(string $name, mixed $parameter)

Sets a parameter value.

Details

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

Constructor.

Parameters

string $baseUrl The base URL
string $method The HTTP method
string $host The HTTP host name
string $scheme The HTTP scheme
int $httpPort The HTTP port
int $httpsPort The HTTPS port
string $path The path
string $queryString The query string

at line 71
public RequestContext fromRequest(Request $request)

Updates the RequestContext information based on a HttpFoundation Request.

Parameters

Request $request A Request instance

Return Value

RequestContext The current instance, implementing a fluent interface

at line 90
public string getBaseUrl()

Gets the base URL.

Return Value

string The base URL

at line 102
public RequestContext setBaseUrl(string $baseUrl)

Sets the base URL.

Parameters

string $baseUrl The base URL

Return Value

RequestContext The current instance, implementing a fluent interface

at line 114
public string getPathInfo()

Gets the path info.

Return Value

string The path info

at line 126
public RequestContext setPathInfo(string $pathInfo)

Sets the path info.

Parameters

string $pathInfo The path info

Return Value

RequestContext The current instance, implementing a fluent interface

at line 140
public string getMethod()

Gets the HTTP method.

The method is always an uppercased string.

Return Value

string The HTTP method

at line 152
public RequestContext setMethod(string $method)

Sets the HTTP method.

Parameters

string $method The HTTP method

Return Value

RequestContext The current instance, implementing a fluent interface

at line 166
public string getHost()

Gets the HTTP host.

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

Return Value

string The HTTP host

at line 178
public RequestContext setHost(string $host)

Sets the HTTP host.

Parameters

string $host The HTTP host

Return Value

RequestContext The current instance, implementing a fluent interface

at line 190
public string getScheme()

Gets the HTTP scheme.

Return Value

string The HTTP scheme

at line 202
public RequestContext setScheme(string $scheme)

Sets the HTTP scheme.

Parameters

string $scheme The HTTP scheme

Return Value

RequestContext The current instance, implementing a fluent interface

at line 214
public int getHttpPort()

Gets the HTTP port.

Return Value

int The HTTP port

at line 226
public RequestContext setHttpPort(int $httpPort)

Sets the HTTP port.

Parameters

int $httpPort The HTTP port

Return Value

RequestContext The current instance, implementing a fluent interface

at line 238
public int getHttpsPort()

Gets the HTTPS port.

Return Value

int The HTTPS port

at line 250
public RequestContext setHttpsPort(int $httpsPort)

Sets the HTTPS port.

Parameters

int $httpsPort The HTTPS port

Return Value

RequestContext The current instance, implementing a fluent interface

at line 262
public string getQueryString()

Gets the query string.

Return Value

string The query string without the "?"

at line 274
public RequestContext setQueryString(string $queryString)

Sets the query string.

Parameters

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

Return Value

RequestContext The current instance, implementing a fluent interface

at line 287
public array getParameters()

Returns the parameters.

Return Value

array The parameters

at line 299
public RequestContext setParameters(array $parameters)

Sets the parameters.

Parameters

array $parameters The parameters

Return Value

RequestContext The current instance, implementing a fluent interface

at line 313
public mixed getParameter(string $name)

Gets a parameter value.

Parameters

string $name A parameter name

Return Value

mixed The parameter value or null if nonexistent

at line 325
public 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

at line 338
public RequestContext setParameter(string $name, mixed $parameter)

Sets a parameter value.

Parameters

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

Return Value

RequestContext The current instance, implementing a fluent interface