Amiro.CMS API Reference
Amiro.Ru / Manual
Loading search...

The AMI_RequestHTTP class

AMI_Request
   |
   --AMI_RequestHTTP

• Introduction

HTTP request class.

• Class synopsis

AMI_RequestHTTP extends AMI_Request {
/* Properties */
// Parsed url
protected array $aParsedURL = false;
// Request scope
protected array $aScope = array('g' => array(),'p'=>array(),'c'=>array());
// Default scope source
protected string $defaultSource = array('g', 'p');
/* Methods */
// Constructor.
public __construct ( ) returns AMI_RequestHTTP;
// Returns value by specified key.
public get ( string $key, [ mixed $default = null ], [ mixed $source = '_default' ] ) returns mixed;
// Returns cookie value by specified key.
public getCookie ( string $key, [ mixed $default = null ] ) returns mixed;
// Returns environment ($_SERVER / getenv()) value by specified key.
public getEnv ( string $key, [ mixed $default = null ] ) returns mixed;
// Returns whole scope.
public getScope ( [ mixed $source = '_default' ] ) returns array;
// Returns URL or URL part of request.
public getURL ( [ string $urlPart = 'url' ] ) returns String;
// Resets scope.
public reset ( [ string $source = null ] ) returns AMI_RequestHTTP;
// Sets/unsets value by key.
public set ( string $key, [ mixed $value = null ], [ string $source = '_default' ] ) returns AMI_RequestHTTP;
// Setting up and parse URL string.
public setURL ( [ string $newURL = false ] ) returns void;
// Protectes cookies/files modification.
protected checkSource ( string $source ) returns bool;
// Initialize scope.
protected initScopes ( ) returns void;
// Strips slashes recursively.
protected stripSlashesRec ( mixed $entity ) returns mixed;
/* Inherited Methods */
// Returns value by specified key.
public AMI_Request::get ( string $key, [ mixed $default = null ], [ mixed $source = '_default' ] ) returns mixed;
// Returns whole scope.
public AMI_Request::getScope ( [ mixed $source = '_default' ] ) returns array;
// Resets scope.
public AMI_Request::reset ( [ string $source = null ] ) returns AMI_Request;
// Sets/unsets value by key.
public AMI_Request::set ( string $key, [ mixed $value = null ], [ string $source = '_default' ] ) returns AMI_Request;
// Sets default scope.
public AMI_Request::setDefaultSource ( mixed $source ) returns AMI_Request;
// Sets whole scope.
public AMI_Request::setScope ( $aScope, string $source ) returns AMI_Request;
// Replace source by default value if needed.
protected AMI_Request::patchSource ( string &$source, [ bool $extractFirst = FALSE ] ) returns void;
}

• Class Details

Default scope set to GET, POST (array('g', 'p')).
Available scopes:
  • g GET (get/set)
  • p POST (get/set)
  • c COOKIE (get)
  • f FILES (get)
Tags:
resource env/request AMI::getSingleton('env/request')

• Class Properies

protected array $aParsedURL

Parsed url

protected array $aScope

Request scope

protected string $defaultSource

Default scope source

• Class Methods

// Constructor.
public __construct ( ) returns AMI_RequestHTTP;
// Returns value by specified key.
public get ( string $key, [ mixed $default = null ], [ mixed $source = '_default' ] ) returns mixed;
  • string $key
    Request key
  • mixed $default
    Default value, will be returned if there is no key in the request
  • mixed $source
    Scope source, array (several sources will be scanned) or string, if not specified, default source is used, since 5.14.8

Overrides: AMI_Request::get().

Usage example:
  •  $oRequest AMI::getSingleton('env/request');
  •  // To get query, post, or cookie value is set any:
  •  $oRequest->get('my_var'nullarray('g''p''c'));
  •  // To get post, query value is set any:
  •  $oRequest->get('my_var'nullarray('p''g'));
  •  // To get uploaded files:
  •  $oRequest->get('...'nullarray('f'));
// Returns cookie value by specified key.
public getCookie ( string $key, [ mixed $default = null ] ) returns mixed;
  • string $key
    Request key
  • mixed $default
    Default value, will be returned if there is no key in the cookies
// Returns environment ($_SERVER / getenv()) value by specified key.
public getEnv ( string $key, [ mixed $default = null ] ) returns mixed;
  • string $key
    Request key
  • mixed $default
    Default value, will be returned if there is no key in the environment
// Returns whole scope.
public getScope ( [ mixed $source = '_default' ] ) returns array;
  • mixed $source
    Scope source, if not specified, default source is used, since 5.14.8

Overrides: AMI_Request::getScope().

If $source argument is array, the sum of scopes will be returned.
// Returns URL or URL part of request.
public getURL ( [ string $urlPart = 'url' ] ) returns String;
  • string $urlPart
    None or: host, port, script, url, uri, path
Tags:
since 5.12.4
// Resets scope.
public reset ( [ string $source = null ] ) returns AMI_RequestHTTP;
  • string $source
    Scope source

Overrides: AMI_Request::reset().

Resetting scope is forbidden in AMI_RequestHTTP.
// Sets/unsets value by key.
public set ( string $key, [ mixed $value = null ], [ string $source = '_default' ] ) returns AMI_RequestHTTP;
  • string $key
    Request key
  • mixed $value
    Null to unset
  • string $source
    Scope source, if not specified, default source is used, since 5.14.8

Overrides: AMI_Request::set().

If $source argument is array, first source scope will be modified.
// Setting up and parse URL string.
public setURL ( [ string $newURL = false ] ) returns void;
  • string $newURL
    Url string, if none - use current.
Tags:
since 5.12.4
// Protectes cookies/files modification.
protected checkSource ( string $source ) returns bool;
  • string $source
    Scope source
Tags:
since 5.14.8
// Initialize scope.
protected initScopes ( ) returns void;
Tags:
since 5.14.8
// Strips slashes recursively.
protected stripSlashesRec ( mixed $entity ) returns mixed;
  • mixed $entity
    Entity
Tags:
since 5.14.8