Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
RestServer Class Reference

Rest server base class. More...

+ Inheritance diagram for RestServer:

Public Member Functions

 __construct (&$config, $headers=null)
 
 connect ($datas=null)
 Establishes the connection with the server, returns an added token in the Authorization header of the request.
 
 refreshToken ()
 Refresh an active token.
 
 isValid ($callback)
 Check if token is valid.
 
 _getHeaderToken ()
 
 finalizeTokens ()
 
 _getHeader ($header)
 
 _addHeaderToken ($token)
 
 _loadApiTokens ()
 
 _header ($headerField, $value=null, bool $replace=true)
 
 _setContentType ($contentType=null, $charset=null)
 
 cors ()
 
 setAllowedOrigin ($address=' *')
 Adds an unique allowed origin for access control.
 
 setAllowedOrigins ($addresses)
 Sets the allowed origins for access control.
 
 addAllowedOrigin ($address)
 Adds an allowed origin for access control.
 
 setTokenLength ($tokenLength)
 
 setTokenDuration ($tokenDuration)
 

Static Public Member Functions

static getRestNamespace ()
 

Protected Member Functions

 getApiTokens ()
 
 newApiTokens ()
 To override for defining another ApiToken type.
 
 getAllowedOrigin ()
 
 setAccessControlAllowOriginHeader ()
 
 addOtherHeaders ()
 

Protected Attributes

 $config
 
 $headers
 
 $tokensFolder
 
 $tokenLength
 
 $tokenDuration
 
 $tokensCacheKey = '_apiTokens'
 
 $allowedOrigins
 
 $apiTokens
 

Private Member Functions

 tokenCallback ($callback)
 

Detailed Description

Rest server base class.

Ubiquity\controllers\rest$RestServer This class is part of Ubiquity

Author
jcheron myadd.nosp@m.ress.nosp@m.mail@.nosp@m.gmai.nosp@m.l.com
Version
1.0.8

Definition at line 21 of file RestServer.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $config,
  $headers = null 
)

Definition at line 40 of file RestServer.php.

Member Function Documentation

◆ _addHeaderToken()

_addHeaderToken (   $token)

Definition at line 135 of file RestServer.php.

◆ _getHeader()

_getHeader (   $header)

Definition at line 127 of file RestServer.php.

◆ _getHeaderToken()

_getHeaderToken ( )

Definition at line 101 of file RestServer.php.

◆ _header()

_header (   $headerField,
  $value = null,
bool  $replace = true 
)
Parameters
string$headerField
string$value
boolean$replace

Definition at line 188 of file RestServer.php.

◆ _loadApiTokens()

_loadApiTokens ( )

Definition at line 139 of file RestServer.php.

◆ _setContentType()

_setContentType (   $contentType = null,
  $charset = null 
)
Parameters
string$contentTypedefault application/json
string$charsetdefault utf8

Definition at line 204 of file RestServer.php.

◆ addAllowedOrigin()

addAllowedOrigin (   $address)

Adds an allowed origin for access control.

Parameters
string$address

Definition at line 264 of file RestServer.php.

◆ addOtherHeaders()

addOtherHeaders ( )
protected

Definition at line 176 of file RestServer.php.

◆ connect()

connect (   $datas = null)

Establishes the connection with the server, returns an added token in the Authorization header of the request.

Returns
array

Definition at line 62 of file RestServer.php.

◆ cors()

cors ( )

Definition at line 212 of file RestServer.php.

◆ finalizeTokens()

finalizeTokens ( )

Definition at line 120 of file RestServer.php.

◆ getAllowedOrigin()

getAllowedOrigin ( )
protected

Definition at line 159 of file RestServer.php.

◆ getApiTokens()

getApiTokens ( )
protected

Definition at line 143 of file RestServer.php.

◆ getRestNamespace()

static getRestNamespace ( )
static

Definition at line 230 of file RestServer.php.

◆ isValid()

isValid (   $callback)

Check if token is valid.

Parameters
callable$callback
Returns
boolean
Exceptions
RestException

Definition at line 86 of file RestServer.php.

◆ newApiTokens()

newApiTokens ( )
protected

To override for defining another ApiToken type.

Returns
ApiTokens

Definition at line 155 of file RestServer.php.

◆ refreshToken()

refreshToken ( )

Refresh an active token.

Returns
array
Exceptions
RestException

Definition at line 73 of file RestServer.php.

◆ setAccessControlAllowOriginHeader()

setAccessControlAllowOriginHeader ( )
protected

Definition at line 170 of file RestServer.php.

◆ setAllowedOrigin()

setAllowedOrigin (   $address = '*')

Adds an unique allowed origin for access control.

Parameters
string$address

Definition at line 242 of file RestServer.php.

◆ setAllowedOrigins()

setAllowedOrigins (   $addresses)

Sets the allowed origins for access control.

Parameters
array$addresses

Definition at line 255 of file RestServer.php.

◆ setTokenDuration()

setTokenDuration (   $tokenDuration)
Parameters
mixed$tokenDuration

Definition at line 280 of file RestServer.php.

◆ setTokenLength()

setTokenLength (   $tokenLength)
Parameters
int$tokenLength

Definition at line 272 of file RestServer.php.

◆ tokenCallback()

tokenCallback (   $callback)
private

Definition at line 49 of file RestServer.php.

Field Documentation

◆ $allowedOrigins

$allowedOrigins
protected

Definition at line 32 of file RestServer.php.

◆ $apiTokens

$apiTokens
protected

Definition at line 38 of file RestServer.php.

◆ $config

$config
protected

Definition at line 26 of file RestServer.php.

◆ $headers

$headers
protected

Definition at line 27 of file RestServer.php.

◆ $tokenDuration

$tokenDuration
protected

Definition at line 30 of file RestServer.php.

◆ $tokenLength

$tokenLength
protected

Definition at line 29 of file RestServer.php.

◆ $tokensCacheKey

$tokensCacheKey = '_apiTokens'
protected

Definition at line 31 of file RestServer.php.

◆ $tokensFolder

$tokensFolder
protected

Definition at line 28 of file RestServer.php.


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