abstract class AbstractAction implements ArrayAccess

Base class for all api actions.

Properties

protected int $version Api version number; cannot be changed.
protected array $chain Additional api requests - will be called once per result.
protected bool $checkPermissions Whether to enforce acl permissions based on the current user.
protected string $_entityName
protected string $_actionName

Methods

__construct(string $entityName, string $actionName)

Action constructor.

__set($name, $value)

Strictly enforce api parameters

$this
setVersion(int $val)

No description

$this
addChain(string $name, AbstractAction $apiRequest, string|int $index = NULL)

No description

__call($name, $arguments)

Magic function to provide addFoo, getFoo and setFoo for params.

execute()

Invoke api call.

_run(Result $result)

No description

array
getParams()

Serialize this object's params into an array

array
getParamInfo(string $param = NULL)

Get documentation for one or all params

string
getEntityName()

No description

string
getActionName()

No description

bool
paramExists(string $param)

No description

array
getParamDefaults()

No description

offsetExists($offset)

No description

offsetGet($offset)

No description

offsetSet($offset, $value)

No description

offsetUnset($offset)

No description

bool
isAuthorized()

Is this api call permitted?

array
getPermissions()

No description

array
entityFields()

Returns schema fields for this entity & action.

reflect()

No description

array
checkRequiredFields($values)

Validates required fields for actions which create a new object.

bool
evaluateCondition(string $expr, array $vars)

This function is used internally for evaluating field annotations.

bool
getCheckPermissions()

No description

array
getChain()

No description

Details

at line 133
__construct(string $entityName, string $actionName)

Action constructor.

Parameters

string $entityName
string $actionName

Exceptions

API_Exception

at line 149
__set($name, $value)

Strictly enforce api parameters

Parameters

$name
$value

Exceptions

Exception

at line 158
$this setVersion(int $val)

Parameters

int $val

Return Value

$this

Exceptions

API_Exception

at line 174
$this addChain(string $name, AbstractAction $apiRequest, string|int $index = NULL)

Parameters

string $name Unique name for this chained request
AbstractAction $apiRequest
string|int $index Either a string for how the results should be indexed e.g. 'name' or the index of a single result to return e.g. 0 for the first result.

Return Value

$this

at line 187
AbstractAction|mixed __call($name, $arguments)

Magic function to provide addFoo, getFoo and setFoo for params.

Parameters

$name
$arguments

Return Value

AbstractAction|mixed

Exceptions

API_Exception

at line 231
Result execute()

Invoke api call.

At this point all the params have been sent in and we initiate the api call & return the result. This is basically the outer wrapper for api v4.

Return Value

Result

Exceptions

UnauthorizedException

at line 241
abstract _run(Result $result)

Parameters

Result $result

at line 247
array getParams()

Serialize this object's params into an array

Return Value

array

at line 265
array getParamInfo(string $param = NULL)

Get documentation for one or all params

Parameters

string $param

Return Value

array of arrays [description, type, default, (comment)]

at line 282
string getEntityName()

Return Value

string

at line 290
string getActionName()

Return Value

string

at line 298
bool paramExists(string $param)

Parameters

string $param

Return Value

bool

at line 305
protected array getParamDefaults()

Return Value

array

at line 312
offsetExists($offset)

Parameters

$offset

at line 319
offsetGet($offset)

Parameters

$offset

at line 344
offsetSet($offset, $value)

Parameters

$offset
$value

at line 359
offsetUnset($offset)

Parameters

$offset

at line 373
bool isAuthorized()

Is this api call permitted?

This function is called if checkPermissions is set to true.

Return Value

bool

at line 381
array getPermissions()

Return Value

array

at line 410
array entityFields()

Returns schema fields for this entity & action.

Here we bypass the api wrapper and execute the getFields action directly. This is because we DON'T want the wrapper to check permissions as this is an internal op, but we DO want permissions to be checked inside the getFields request so e.g. the api_key field can be conditionally included.

Return Value

array

See also

GetFields

at line 429
ReflectionClass reflect()

Return Value

ReflectionClass

at line 443
protected array checkRequiredFields($values)

Validates required fields for actions which create a new object.

Parameters

$values

Return Value

array

Exceptions

API_Exception

at line 473
protected bool evaluateCondition(string $expr, array $vars)

This function is used internally for evaluating field annotations.

It should never be passed raw user input.

Parameters

string $expr Conditional in php format e.g. $foo > $bar
array $vars Variable name => value

Return Value

bool

Exceptions

API_Exception
Exception

at line 50
bool getCheckPermissions()

Return Value

bool

at line 50
array getChain()

Return Value

array