FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Request Class Reference

Component comprising all information regarding an HTTP-request (to transport these along all stepts executed during a request). More...

Inheritance diagram for Request:
Component Thing

Public Member Functions

 mapArgs ($keys=null)
 Map command line arguments to the $_GET. More...
 
 file ($key)
 Retrieve a file upload from the request. More...
 
 complex ($key, $default=null)
 Retrieve a complex parameter (simple type or array) from the request. More...
 
 record ($key, $default=null)
 Retrieve a record like parameter (single layer array) from the request. More...
 
 simple ($key, $default=null, $mask=null)
 Retrieve a simple parameter (not an array) from the request. More...
 
 data ($key, $default=null)
 
 cookie ($key, $value=null, $days=365, $options=null)
 Set and/or get a cookie. More...
 
 __invoke ($key, $default=null)
 
- Public Member Functions inherited from Component
 __construct ($fred, $config=null)
 
 __destruct ()
 
 clientConfig ()
 Public configuration. More...
 
 config ($key, $default=null)
 Retrieve a config value. More...
 
 ping ()
 Ping function. More...
 
 filemtime ($filename)
 Filemtime with session cache. More...
 
 component ($name)
 Get a component (local or default). More...
 
 components (... $names)
 Get multiple components in an array. More...
 
- Public Member Functions inherited from Thing
 propertyExists ($property)
 Check if a property exists (public or published). More...
 
 constants ($prefix=null)
 Return all constants. More...
 
 get ($key)
 Get one or more properties. More...
 
 set ($key, $value=null)
 Set one or more properties. More...
 
 __get ($key)
 
 __set ($key, $value)
 

Data Fields

 $encoding = 'UTF-8'
 Check encoding. More...
 
 $errors = []
 Errors detected during the processing of the request (key = item ID, value = error code). More...
 
 $data = []
 Data to be presented by the view (key-value pairs). More...
 
 $result = null
 Result fo the request (mixed). More...
 
 $redir = null
 URL for redirection (empty = no redirection). More...
 
 $viewControllerName = null
 Name of the view controller (same as the request handler when empty). More...
 
 $cookieOptions = []
 Default cookie options. More...
 
 $jsonDecodingError = 'JSON decoding error: [error]'
 
 $postExceededError = 'POST exceeded ([size] / [max])'
 
- Data Fields inherited from Component
 $filemtimeTtl = 0
 
- Data Fields inherited from Thing
const HIDDEN = 0
 Property is hidden. More...
 
const READABLE = 1
 Property is readable. More...
 
const WRITEABLE = 2
 Property is writeable. More...
 
const READWRITE = 3
 Property is readable and writeable. More...
 

Protected Member Functions

 init ()
 
 checkPost ()
 Checks the post (by content type). More...
 
 fixFileKey ($values, $prefix=null, $files=null)
 Transform an array of uploaded files to a 'normal' structure. More...
 
 getFiles ()
 
 getServer ()
 
 _get ($key)
 
 _set ($key, $value)
 
- Protected Member Functions inherited from Component
 init ()
 
 done ()
 
 getSession ()
 
- Protected Member Functions inherited from Thing
 publish ($property, $visibility=self::READABLE)
 Publish a property (or hide it again). More...
 
 configure ($config)
 Configure the object. More...
 
 _get ($key)
 Default getter if no specific setter is defined, and the property is also not published (readable). More...
 
 _set ($key, $value)
 Default setter if no specific setter is defined, and the property is also not published (writeable). More...
 

Protected Attributes

 $_files = null
 
 $_server = null
 
- Protected Attributes inherited from Component
 $_fred = null
 
 $_config = null
 
 $_name = null
 
 $_components = []
 Local components (key = component name, value = component). More...
 
 $_session = null
 
- Protected Attributes inherited from Thing
 $_published = []
 Published properties (key = name of property, value = visibility). More...
 

Detailed Description

Component comprising all information regarding an HTTP-request (to transport these along all stepts executed during a request).

Definition at line 9 of file Request.php.

Member Function Documentation

◆ __invoke()

__invoke (   $key,
  $default = null 
)

Definition at line 180 of file Request.php.

◆ _get()

_get (   $key)
protected

Definition at line 172 of file Request.php.

◆ _set()

_set (   $key,
  $value 
)
protected

Definition at line 176 of file Request.php.

◆ checkPost()

checkPost ( )
protected

Checks the post (by content type).

Definition at line 32 of file Request.php.

◆ complex()

complex (   $key,
  $default = null 
)

Retrieve a complex parameter (simple type or array) from the request.

Parameters are first sought-after in the $_POST, then in the $_FILES, and last in the $_GET. Only the latter will be done case insensitive.

Parameters
string$keyName of the sought parameter.
mixed$defaultDefault value if the key does not exist.
Returns
mixed Found value, or default value if the key does not exist.

Definition at line 103 of file Request.php.

◆ cookie()

cookie (   $key,
  $value = null,
  $days = 365,
  $options = null 
)

Set and/or get a cookie.

Parameters
string$keyCookie key.
mixed$valueCookie value.
int$daysCookie lifetime (in days).
array$optionsCookie options (see https://www.php.net/setcookie; when 'secure' is undefined, the value is automaticly set to true when the request was made using a secure connection).
Returns
mixed Cookie value (false when unknown).

Definition at line 148 of file Request.php.

◆ data()

data (   $key,
  $default = null 
)

Definition at line 136 of file Request.php.

◆ file()

file (   $key)

Retrieve a file upload from the request.

Parameters
string$keyName of the sought file.
Returns
mixed Found value (might be empty or have errors).

Definition at line 92 of file Request.php.

◆ fixFileKey()

fixFileKey (   $values,
  $prefix = null,
  $files = null 
)
protected

Transform an array of uploaded files to a 'normal' structure.

Single file uploads have an entry in the $_FILES array with properties 'tmp_name', 'size', and so on. With an array of files this is also the case, and each of these property has a multi dimensional array of values. For the processing of single files though it is more convinient if all files have the same single dimension array structure as the single file upload at the deepest level. Therefore the property names must move to the end of the structure.

Parameters
array$valuesArray with properties (single or multi dimensional).
array$prefixArray to prefix before the keys.
array$filesAlready determined, correct structure.
Returns
array Complemented, correct structure.

Definition at line 64 of file Request.php.

◆ getFiles()

getFiles ( )
protected

Definition at line 153 of file Request.php.

◆ getServer()

getServer ( )
protected

Definition at line 161 of file Request.php.

◆ init()

init ( )
protected

Definition at line 25 of file Request.php.

◆ mapArgs()

mapArgs (   $keys = null)

Map command line arguments to the $_GET.

Parameters
array$keysArray with key for every consecutive argument. If empty, the argument itself is parsed for keys ("key=value foo=bar" format).

Definition at line 81 of file Request.php.

◆ record()

record (   $key,
  $default = null 
)

Retrieve a record like parameter (single layer array) from the request.

See also
complex()
Parameters
string$keyName of the sought parameter.
mixed$defaultDefault value if the key does not exist.
Returns
mixed Found value, or default value if the key does not exist or the value is not valid.

Definition at line 115 of file Request.php.

◆ simple()

simple (   $key,
  $default = null,
  $mask = null 
)

Retrieve a simple parameter (not an array) from the request.

See also
complex()
Parameters
string$keyName of the sought parameter.
mixed$defaultDefault value if the key does not exist.
string$maskRegex to check the value with (true = word chars only).
Returns
mixed Found value, or default value if the key does not exist or the value is not valid.

Definition at line 128 of file Request.php.

Field Documentation

◆ $_files

$_files = null
protected

Definition at line 22 of file Request.php.

◆ $_server

$_server = null
protected

Definition at line 23 of file Request.php.

◆ $cookieOptions

$cookieOptions = []

Default cookie options.

Definition at line 18 of file Request.php.

◆ $data

$data = []

Data to be presented by the view (key-value pairs).

Definition at line 13 of file Request.php.

◆ $encoding

$encoding = 'UTF-8'

Check encoding.

Definition at line 11 of file Request.php.

◆ $errors

$errors = []

Errors detected during the processing of the request (key = item ID, value = error code).

Definition at line 12 of file Request.php.

◆ $jsonDecodingError

$jsonDecodingError = 'JSON decoding error: [error]'

Definition at line 19 of file Request.php.

◆ $postExceededError

$postExceededError = 'POST exceeded ([size] / [max])'

Definition at line 20 of file Request.php.

◆ $redir

$redir = null

URL for redirection (empty = no redirection).

Definition at line 15 of file Request.php.

◆ $result

$result = null

Result fo the request (mixed).

Definition at line 14 of file Request.php.

◆ $viewControllerName

$viewControllerName = null

Name of the view controller (same as the request handler when empty).

Definition at line 16 of file Request.php.


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