PHP Class RestComponent, cakephp-rest-plugin

Inheritance: extends Object
ファイルを表示 Open project: kvz/cakephp-rest-plugin

Public Properties

Property Type Description
$Controller
$codes
$isActive string Should the rest plugin be active?
$postData
$settings

Protected Properties

Property Type Description
$_RestLog
$_View
$_aborting
$_credentials
$_feedback
$_logData

Public Methods

Method Description
RestLog ( ) : object Return an instance of the log model
View ( boolean $object = true, string $ext = null ) : mixed Returns either string or reference to active View object
__call ( string $name, array $arguments ) Catch & fire callbacks. You can map callbacks to different places using the value parts in $this->settings['callbacks'].
__construct ( ComponentCollection $collection, $settings = [] )
abort ( $params = [], $data = [] ) Could be called by e.g. ->redirect to dump an error & stop further execution.
beforeRedirect ( Controller $Controller, $url, $status = null, $exit = true )
beforeRender ( Controller $Controller ) : Collects viewVars, reformats, and makes them available as viewVar: response for use in REST serialization
controllers ( boolean $cached = true ) : array Returns a list of Controllers where Rest component has been activated uses Cache::read & Cache::write by default to tackle performance issues.
credentials ( $set = false ) : Sets or returns credentials as found in the 'Authorization' header sent by the client.
debug ( $format, $arg1 = null, $arg2 = null )
error ( $format, $arg1 = null, $arg2 = null )
getFeedBack ( boolean $format = false ) : array Returns (optionally) formatted feedback.
headers ( $ext = null ) : Set content-type headers based on extension
info ( $format, $arg1 = null, $arg2 = null )
initialize ( Controller $Controller )
inject ( array $take, array $viewVars ) : array Reformats data according to Xpaths in $take
isActive ( )
log ( mixed $key, mixed $val = null, $scope = null ) : boolean log(true) writes log to disk. otherwise stores key-value pairs in memory for later saving. Can also work recursively by giving an array as the key
numeric ( array $array = [] ) : boolean Determines is an array is numerically indexed
ratelimit ( $time, $max ) : Works together with Logging to ratelimit incomming requests by identfield
response ( array $data = [] ) : array Get an array of everything that needs to go into the Xml / Json
shutdown ( Controller $Controller ) Write the accumulated logentry
startup ( Controller $Controller ) : Controls layout & view files
validate ( $format, $arg1 = null, $arg2 = null )
warning ( $format, $arg1 = null, $arg2 = null )

Protected Methods

Method Description
_modelizePost ( &$data ) : Prepares REST data for cake interaction

Method Details

RestLog() public method

Return an instance of the log model
public RestLog ( ) : object
return object

View() public method

Returns either string or reference to active View object
public View ( boolean $object = true, string $ext = null ) : mixed
$object boolean
$ext string
return mixed object or string

__call() public method

If the resolved callback is a string we assume it's in the controller.
public __call ( string $name, array $arguments )
$name string
$arguments array

__construct() public method

public __construct ( ComponentCollection $collection, $settings = [] )
$collection ComponentCollection

_modelizePost() protected method

Prepares REST data for cake interaction
protected _modelizePost ( &$data ) :
$data
return

abort() public method

Could be called by e.g. ->redirect to dump an error & stop further execution.
public abort ( $params = [], $data = [] )
$params
$data

beforeRedirect() public method

public beforeRedirect ( Controller $Controller, $url, $status = null, $exit = true )
$Controller Controller

beforeRender() public method

Collects viewVars, reformats, and makes them available as viewVar: response for use in REST serialization
public beforeRender ( Controller $Controller ) :
$Controller Controller
return

controllers() public method

Returns a list of Controllers where Rest component has been activated uses Cache::read & Cache::write by default to tackle performance issues.
public controllers ( boolean $cached = true ) : array
$cached boolean
return array

credentials() public method

Have your client set a header like: Authorization: TRUEREST username=john&password=xxx&apikey=247b5a2f72df375279573f2746686daa< http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?RESTAuthentication.html credentials(true) sets credentials credentials() returns full array credentials('username') returns username
public credentials ( $set = false ) :
return

debug() public method

public debug ( $format, $arg1 = null, $arg2 = null )

error() public method

public error ( $format, $arg1 = null, $arg2 = null )

getFeedBack() public method

Returns (optionally) formatted feedback.
public getFeedBack ( boolean $format = false ) : array
$format boolean
return array

headers() public method

Set content-type headers based on extension
public headers ( $ext = null ) :
$ext
return

info() public method

public info ( $format, $arg1 = null, $arg2 = null )

initialize() public method

public initialize ( Controller $Controller )
$Controller Controller

inject() public method

Reformats data according to Xpaths in $take
public inject ( array $take, array $viewVars ) : array
$take array
$viewVars array
return array

isActive() public method

public isActive ( )

log() public method

log(true) writes log to disk. otherwise stores key-value pairs in memory for later saving. Can also work recursively by giving an array as the key
public log ( mixed $key, mixed $val = null, $scope = null ) : boolean
$key mixed
$val mixed
return boolean

numeric() public method

Determines is an array is numerically indexed
public numeric ( array $array = [] ) : boolean
$array array
return boolean

ratelimit() public method

Works together with Logging to ratelimit incomming requests by identfield
public ratelimit ( $time, $max ) :
return

response() public method

Get an array of everything that needs to go into the Xml / Json
public response ( array $data = [] ) : array
$data array optional. Data collected by cake
return array

shutdown() public method

Write the accumulated logentry
public shutdown ( Controller $Controller )
$Controller Controller

startup() public method

Controls layout & view files
public startup ( Controller $Controller ) :
$Controller Controller
return

validate() public method

public validate ( $format, $arg1 = null, $arg2 = null )

warning() public method

public warning ( $format, $arg1 = null, $arg2 = null )

Property Details

$Controller public_oe property

public $Controller

$_RestLog protected_oe property

protected $_RestLog

$_View protected_oe property

protected $_View

$_aborting protected_oe property

protected $_aborting

$_credentials protected_oe property

protected $_credentials

$_feedback protected_oe property

protected $_feedback

$_logData protected_oe property

protected $_logData

$codes public_oe property

public $codes

$isActive public_oe property

Should the rest plugin be active?
public string $isActive
return string

$postData public_oe property

public $postData

$settings public_oe property

public $settings