class Request implements RequestInterface

The global request class

Constants

NO_REWRITE

REWRITE_SEGMENTS_QUERY

Methods

static  Request
create( string $url = null, int $flag = self::NO_REWRITE, string $protocol = 'http', string $method = 'get', array $headers = null, array $arguments = null, array $data = null, array $session = null, array $files = null, array $cookies = null)

Static constructor : defines the current URL and gets the routes

__construct( string $url = null, int $flag = self::NO_REWRITE)

Constructor : defines the request URL and the object rewrite flag

$this
guessFromCurrent()

Populate the request object with current HTTP request values

$this
setFlag( int $flag)

No description

int
getFlag()

No description

$this
setUrl( string $url)

No description

string|null
getUrl()

No description

$this
setProtocol( string $protocol)

No description

string|null
getProtocol()

No description

$this
setMethod( string $method)

No description

string|null
getMethod()

No description

$this
setHeaders( array $headers = null)

No description

array|null
getHeaders()

No description

string|null
getHeader( string $name)

No description

$this
setArguments( string|array $arguments = null)

No description

array|null
getArguments( bool $clean = true, int $clean_flags = ENT_COMPAT, string $clean_encoding = 'UTF-8')

No description

string
getArgument( string $param = null, mixed $default = false, bool $clean = true, int $clean_flags = ENT_COMPAT, string $clean_encoding = 'UTF-8')

No description

$this
setData( array|string $data = null)

No description

string
getData( string $param = null, mixed $default = false, bool $clean = true, int $clean_flags = ENT_COMPAT, string $clean_encoding = 'UTF-8')

No description

$this
setFiles( array $files = null)

No description

array|null
getFiles()

No description

array|null
getFile( string $param, string $index = null)

No description

$this
setSession( array $session = null)

No description

array|null
getSession( string $param = null)

No description

$this
setCookies( array $cookies = null)

No description

array|null
getCookies()

No description

array|null
getCookie( string $param)

No description

$this
setAuthentication( array $authentication = null)

No description

$this
setAuthenticationType( string $type)

No description

$this
setAuthenticationUser( string $user)

No description

$this
setAuthenticationPassword( string $pw)

No description

array|string|null
getAuthentication( string $param = null)

No description

string
buildUrl()

No description

static  bool
isAjax()

No description

bool
isCli()

No description

bool
isGet()

No description

bool
isPost()

No description

bool
isPut()

No description

mixed|false
getGet( string $varname, mixed $default = null)

No description

mixed|false
getPost( string $varname, mixed $default = null)

No description

mixed|false
getGetOrPost( string $varname, mixed $default = null)

No description

mixed|false
getPostOrGet( string $varname, mixed $default = null)

No description

static  string
cleanArgument( string $arg_value, int $flags = ENT_COMPAT, string $encoding = 'UTF-8')

Clean the value taken from request arguments or data

static  mixed|false
getEnvironment( string $varname)

No description

static  string|null
getReferer()

Get the current request referer if available

static  string
getClientIp()

No description

static 
getallheaders()

Emulation of internal getallheaders() function as it does not exist each time

Details

at line 121
static Request create( string $url = null, int $flag = self::NO_REWRITE, string $protocol = 'http', string $method = 'get', array $headers = null, array $arguments = null, array $data = null, array $session = null, array $files = null, array $cookies = null)

Static constructor : defines the current URL and gets the routes

Parameters

string $url
int $flag
string $protocol
string $method
array $headers
array $arguments
array $data
array $session
array $files
array $cookies

Return Value

Request

at line 166
__construct( string $url = null, int $flag = self::NO_REWRITE)

Constructor : defines the request URL and the object rewrite flag

Parameters

string $url
int $flag Must be one of the class REWRITE constants

at line 182
$this guessFromCurrent()

Populate the request object with current HTTP request values

Return Value

$this

See also

\Library\Helper\Url::getRequestUrl()

at line 209
$this setFlag( int $flag)

Parameters

int $flag Must be one of the class REWRITE constants

Return Value

$this

at line 218
int getFlag()

Return Value

int

at line 227
$this setUrl( string $url)

Parameters

string $url

Return Value

$this

at line 236
string|null getUrl()

Return Value

string|null

at line 245
$this setProtocol( string $protocol)

Parameters

string $protocol

Return Value

$this

at line 254
string|null getProtocol()

Return Value

string|null

at line 263
$this setMethod( string $method)

Parameters

string $method

Return Value

$this

at line 272
string|null getMethod()

Return Value

string|null

at line 281
$this setHeaders( array $headers = null)

Parameters

array $headers

Return Value

$this

at line 290
array|null getHeaders()

Return Value

array|null

at line 299
string|null getHeader( string $name)

Parameters

string $name

Return Value

string|null

at line 308
$this setArguments( string|array $arguments = null)

Parameters

string|array $arguments

Return Value

$this

at line 326
array|null getArguments( bool $clean = true, int $clean_flags = ENT_COMPAT, string $clean_encoding = 'UTF-8')

Parameters

bool $clean Clean the argument before return ? (default is true)
int $clean_flags The PHP flags used with htmlspecialchars() (default is ENT_COMPAT)
string $clean_encoding The encoding used with htmlspecialchars() (default is UTF-8)

Return Value

array|null

at line 340
string getArgument( string $param = null, mixed $default = false, bool $clean = true, int $clean_flags = ENT_COMPAT, string $clean_encoding = 'UTF-8')

Parameters

string $param The parameter name if so, or 'args' to get all parameters values
mixed $default The default value sent if the argument is not set
bool $clean Clean the argument before return ? (default is true)
int $clean_flags The PHP flags used with htmlspecialchars() (default is ENT_COMPAT)
string $clean_encoding The encoding used with htmlspecialchars() (default is UTF-8)

Return Value

string The value retrieved, $default otherwise

at line 353
$this setData( array|string $data = null)

Parameters

array|string $data

Return Value

$this

at line 370
string getData( string $param = null, mixed $default = false, bool $clean = true, int $clean_flags = ENT_COMPAT, string $clean_encoding = 'UTF-8')

Parameters

string $param The parameter name if so, or 'args' to get all parameters values
mixed $default The default value sent if the argument is not set
bool $clean Clean the argument before return ? (default is true)
int $clean_flags The PHP flags used with htmlspecialchars() (default is ENT_COMPAT)
string $clean_encoding The encoding used with htmlspecialchars() (default is UTF-8)

Return Value

string The value retrieved, $default otherwise

at line 388
$this setFiles( array $files = null)

Parameters

array $files

Return Value

$this

at line 397
array|null getFiles()

Return Value

array|null

at line 407
array|null getFile( string $param, string $index = null)

Parameters

string $param
string $index

Return Value

array|null

at line 423
$this setSession( array $session = null)

Parameters

array $session

Return Value

$this

at line 433
array|null getSession( string $param = null)

Parameters

string $param

Return Value

array|null

at line 446
$this setCookies( array $cookies = null)

Parameters

array $cookies

Return Value

$this

at line 455
array|null getCookies()

Return Value

array|null

at line 464
array|null getCookie( string $param)

Parameters

string $param

Return Value

array|null

at line 473
$this setAuthentication( array $authentication = null)

Parameters

array $authentication

Return Value

$this

at line 483
$this setAuthenticationType( string $type)

Parameters

string $type

Return Value

$this

at line 493
$this setAuthenticationUser( string $user)

Parameters

string $user

Return Value

$this

at line 503
$this setAuthenticationPassword( string $pw)

Parameters

string $pw

Return Value

$this

at line 513
array|string|null getAuthentication( string $param = null)

Parameters

string $param

Return Value

array|string|null

at line 529
string buildUrl()

Return Value

string

at line 570
static bool isAjax()

Return Value

bool

at line 579
bool isCli()

Return Value

bool

at line 587
bool isGet()

Return Value

bool

at line 595
bool isPost()

Return Value

bool

at line 603
bool isPut()

Return Value

bool

at line 613
mixed|false getGet( string $varname, mixed $default = null)

Parameters

string $varname
mixed $default

Return Value

mixed|false

at line 623
mixed|false getPost( string $varname, mixed $default = null)

Parameters

string $varname
mixed $default

Return Value

mixed|false

at line 633
mixed|false getGetOrPost( string $varname, mixed $default = null)

Parameters

string $varname
mixed $default

Return Value

mixed|false

at line 647
mixed|false getPostOrGet( string $varname, mixed $default = null)

Parameters

string $varname
mixed $default

Return Value

mixed|false

at line 710
static string cleanArgument( string $arg_value, int $flags = ENT_COMPAT, string $encoding = 'UTF-8')

Clean the value taken from request arguments or data

Parameters

string $arg_value The parameter name if so, or 'args' to get all parameters values
int $flags The PHP flags used with htmlspecialchars() (default is ENT_COMPAT)
string $encoding The encoding used with htmlspecialchars() (default is UTF-8)

Return Value

string The cleaned value

at line 728
static mixed|false getEnvironment( string $varname)

Parameters

string $varname

Return Value

mixed|false

at line 738
static string|null getReferer()

Get the current request referer if available

Return Value

string|null

at line 746
static string getClientIp()

Return Value

string

at line 761
static getallheaders()

Emulation of internal getallheaders() function as it does not exist each time