class StaticProvider extends AdhocProvider

A static provider is useful for creating mock API implementations which manages records in-memory.

TODO Add a static provider to SyntaxConformanceTest to ensure that it's representative.

Properties

protected array $actions from AdhocProvider
protected string $entity from AdhocProvider
protected int $version from AdhocProvider
protected $records
protected $fields

Methods

static array
getSubscribedEvents()

No description

__construct(int $version, string $entity, array $fields, array $perms = array(), array $records = array())

No description

addAction(string $name, string $perm, mixed $callback)

Register a new API.

onApiResolve( $event)

No description

onApiAuthorize( $event)

No description

array
invoke(array $apiRequest)

No description

array
getEntityNames(int $version)

No description

array
getActionNames(int $version, string $entity)

No description

bool
matchesRequest(array $apiRequest)

No description

array
getRecords()

No description

setRecords(array $records)

No description

array
doCreate(array $apiRequest)

No description

array
doGet(array $apiRequest)

No description

array
doDelete(array $apiRequest)

No description

Details

at line 46
static array getSubscribedEvents()

Return Value

array

at line 69
__construct(int $version, string $entity, array $fields, array $perms = array(), array $records = array())

Parameters

int $version API version.
string $entity API entity.
array $fields List of fields in this fake entity.
array $perms Array(string $action => string $perm).
array $records List of mock records to be read/updated by API calls.

in AdhocProvider at line 92
AdhocProvider addAction(string $name, string $perm, mixed $callback)

Register a new API.

Parameters

string $name Action name.
string $perm Permissions required for invoking the action.
mixed $callback The function which executes the API.

Return Value

AdhocProvider

in AdhocProvider at line 104
onApiResolve( $event)

Parameters

$event API resolution event.

in AdhocProvider at line 117
onApiAuthorize( $event)

Parameters

$event API authorization event.

in AdhocProvider at line 130
array invoke(array $apiRequest)

Parameters

array $apiRequest The full description of the API request.

Return Value

array structured response data (per civicrm_api3_create_success)

in AdhocProvider at line 139
array getEntityNames(int $version)

Parameters

int $version API version.

Return Value

array

in AdhocProvider at line 149
array getActionNames(int $version, string $entity)

Parameters

int $version API version.
string $entity API entity.

Return Value

array

in AdhocProvider at line 164
bool matchesRequest(array $apiRequest)

Parameters

array $apiRequest The full description of the API request.

Return Value

bool

at line 89
array getRecords()

Return Value

array

at line 97
setRecords(array $records)

Parameters

array $records List of mock records to be read/updated by API calls.

at line 108
array doCreate(array $apiRequest)

Parameters

array $apiRequest The full description of the API request.

Return Value

array Formatted API result

Exceptions

API_Exception

at line 137
array doGet(array $apiRequest)

Parameters

array $apiRequest The full description of the API request.

Return Value

array Formatted API result

Exceptions

API_Exception

at line 148
array doDelete(array $apiRequest)

Parameters

array $apiRequest The full description of the API request.

Return Value

array Formatted API result

Exceptions

API_Exception