\rex_api_content_copy

This is a base class for all functions which a component may provide for public use.

Summary

Methods
Properties
Constants
execute()
factory()
getUrlParams()
getHiddenFields()
handleCall()
hasMessage()
getMessage()
getResult()
setFactoryClass()
getFactoryClass()
hasFactoryClass()
No public properties found
REQ_CALL_PARAM
REQ_RESULT_PARAM
__construct()
requiresCsrfProtection()
callFactoryClass()
$published
$result
N/A
No private methods found
No private properties found
N/A

Constants

REQ_CALL_PARAM

REQ_CALL_PARAM = 'rex-api-call'

REQ_RESULT_PARAM

REQ_RESULT_PARAM = 'rex-api-result'

Properties

$published

$published : bool

Flag, indicating if this api function may be called from the frontend. False by default.

Type

bool

$result

$result : \rex_api_result

The result of the function call.

Type

rex_api_result

Methods

execute()

execute() : \rex_api_result

This method have to be overriden by a subclass and does all logic which the api function represents.

Throws

\rex_api_exception

Returns

\rex_api_result —

factory()

factory() : self|null

Returns the api function instance which is bound to the current request, or null if no api function was bound.

Throws

\rex_exception

Returns

self|null —

getUrlParams()

getUrlParams() : array

Returns an array containing the `rex-api-call` and `_csrf_token` params.

The method must be called on sub classes.

Returns

array —

getHiddenFields()

getHiddenFields() : string

Returns the hidden fields for `rex-api-call` and `_csrf_token`.

The method must be called on sub classes.

Returns

string —

handleCall()

handleCall() : mixed

checks whether an api function is bound to the current requests. If so, so the api function will be executed.

Returns

mixed —

hasMessage()

hasMessage() : bool

Returns

bool —

getMessage()

getMessage(mixed  $formatted = true) : string

Parameters

mixed $formatted

Returns

string —

getResult()

getResult() : \rex_api_result

Returns

\rex_api_result —

setFactoryClass()

setFactoryClass(string  $subclass) : mixed

Sets the class for the factory.

Parameters

string $subclass

Classname

Throws

\InvalidArgumentException

Returns

mixed —

getFactoryClass()

getFactoryClass() : string

Returns the class for the factory.

Returns

string —

hasFactoryClass()

hasFactoryClass() : bool

Returns if the class has a custom factory class.

Returns

bool —

__construct()

__construct() : mixed

Returns

mixed —

requiresCsrfProtection()

requiresCsrfProtection() : bool

Csrf validation is disabled by default for backwards compatiblity reasons. This default will change in a future version.

Prepare all your api functions to work with csrf token by using your-api-class::getUrlParams()/getHiddenFields(), otherwise they will stop work.

Returns

bool —

callFactoryClass()

callFactoryClass(string  $method, array  $arguments) : mixed

Calls the factory class with the given method and arguments.

Parameters

string $method

Method name

array $arguments

Array of arguments

Returns

mixed —

Result of the callback