AdhocProvider
in package
implements
EventSubscriberInterface, ProviderInterface
An adhoc provider is useful for creating mock API implementations.
Table of Contents
Interfaces
- EventSubscriberInterface
- ProviderInterface
- An API "provider" provides a means to execute API requests.
Properties
Methods
- __construct() : mixed
- addAction() : AdhocProvider
- Register a new API.
- getActionNames() : array<string|int, mixed>
- getEntityNames() : array<string|int, mixed>
- getSubscribedEvents() : array<string|int, mixed>
- invoke() : array<string|int, mixed>|mixed
- matchesRequest() : bool
- onApiAuthorize() : mixed
- onApiResolve() : mixed
Properties
$actions
List of adhoc actions
protected
array<string|int, mixed>
$actions
= []
array(string $ame => array('perm' => string, 'callback' => callable))
$entity
protected
string
$entity
$version
protected
int
$version
Methods
__construct()
public
__construct(int $version, string $entity) : mixed
Parameters
- $version : int
-
API version.
- $entity : string
-
API entity.
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
AdhocProvidergetActionNames()
public
getActionNames(int $version, string $entity) : array<string|int, mixed>
Parameters
- $version : int
- $entity : string
Tags
Return values
array<string|int, mixed>getEntityNames()
public
getEntityNames(int $version) : array<string|int, mixed>
Parameters
- $version : int
Tags
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
Return values
array<string|int, mixed>|mixedmatchesRequest()
public
matchesRequest(array<string|int, mixed> $apiRequest) : bool
Parameters
- $apiRequest : array<string|int, mixed>
-
The full description of the API request.
Return values
boolonApiAuthorize()
public
onApiAuthorize(AuthorizeEvent $event) : mixed
Parameters
- $event : AuthorizeEvent
-
API authorization event.
onApiResolve()
public
onApiResolve(ResolveEvent $event) : mixed
Parameters
- $event : ResolveEvent
-
API resolution event.