Documentation

StaticProvider extends AdhocProvider
in package

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.

Table of Contents

Properties

$actions  : array<string|int, mixed>
List of adhoc actions
$entity  : string
$fields  : mixed
$records  : mixed
$version  : int

Methods

__construct()  : mixed
addAction()  : AdhocProvider
Register a new API.
doCreate()  : array<string|int, mixed>
doDelete()  : array<string|int, mixed>
doGet()  : array<string|int, mixed>
getActionNames()  : array<string|int, mixed>
getEntityNames()  : array<string|int, mixed>
getRecords()  : array<string|int, mixed>
getSubscribedEvents()  : array<string|int, mixed>
invoke()  : array<string|int, mixed>|mixed
matchesRequest()  : bool
onApiAuthorize()  : mixed
onApiResolve()  : mixed
setRecords()  : mixed

Properties

$actions

List of adhoc actions

protected array<string|int, mixed> $actions = []

array(string $ame => array('perm' => string, 'callback' => callable))

Methods

__construct()

public __construct(int $version, string $entity, array<string|int, mixed> $fields[, array<string|int, mixed> $perms = [] ][, array<string|int, mixed> $records = [] ]) : mixed
Parameters
$version : int

API version.

$entity : string

API entity.

$fields : array<string|int, mixed>

List of fields in this fake entity.

$perms : array<string|int, mixed> = []

Array(string $action => string $perm).

$records : array<string|int, mixed> = []

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

addAction()

Register a new API.

public addAction(string $name, string $perm, mixed $callback) : AdhocProvider
Parameters
$name : string

Action name.

$perm : string

Permissions required for invoking the action.

$callback : mixed

The function which executes the API.

Return values
AdhocProvider

doCreate()

public doCreate(array<string|int, mixed> $apiRequest) : array<string|int, mixed>
Parameters
$apiRequest : array<string|int, mixed>

The full description of the API request.

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

Formatted API result

doDelete()

public doDelete(array<string|int, mixed> $apiRequest) : array<string|int, mixed>
Parameters
$apiRequest : array<string|int, mixed>

The full description of the API request.

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

Formatted API result

doGet()

public doGet(array<string|int, mixed> $apiRequest) : array<string|int, mixed>
Parameters
$apiRequest : array<string|int, mixed>

The full description of the API request.

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

Formatted API result

getActionNames()

public getActionNames(int $version, string $entity) : array<string|int, mixed>
Parameters
$version : int
$entity : string
Tags
inheritDoc
Return values
array<string|int, mixed>

getEntityNames()

public getEntityNames(int $version) : array<string|int, mixed>
Parameters
$version : int
Tags
inheritDoc
Return values
array<string|int, mixed>

getRecords()

public getRecords() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSubscribedEvents()

public static getSubscribedEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

invoke()

public invoke(array<string|int, mixed> $apiRequest) : array<string|int, mixed>|mixed
Parameters
$apiRequest : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>|mixed

matchesRequest()

public matchesRequest(array<string|int, mixed> $apiRequest) : bool
Parameters
$apiRequest : array<string|int, mixed>

The full description of the API request.

Return values
bool

setRecords()

public setRecords(array<string|int, mixed> $records) : mixed
Parameters
$records : array<string|int, mixed>

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


        
On this page

Search results