MagicFunctionProvider
in package
implements
EventSubscriberInterface, ProviderInterface
This class manages the loading of API's using strict file+function naming conventions.
Table of Contents
Interfaces
- EventSubscriberInterface
- ProviderInterface
- An API "provider" provides a means to execute API requests.
Properties
- $cache : array<string|int, mixed>
- Local cache of function-mappings.
Methods
- __construct() : mixed
- getActionNames() : array<string|int, mixed>
- getEntityNames() : array<string|int, mixed>
- getSubscribedEvents() : array<string|int, mixed>
- invoke() : array<string|int, mixed>
- onApiResolve() : mixed
- getFunctionName() : string
- Determine the function name for a given API request.
- loadEntity() : mixed
- Load/require all files related to an entity.
- resolve() : array<string|int, mixed>
- Look up the implementation for a given API request.
Properties
$cache
Local cache of function-mappings.
private
array<string|int, mixed>
$cache
array(string $cacheKey => array('function' => string, 'is_generic' => bool))
Methods
__construct()
public
__construct() : mixed
getActionNames()
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>
Parameters
- $apiRequest : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>onApiResolve()
public
onApiResolve(ResolveEvent $event) : mixed
Parameters
- $event : ResolveEvent
-
API resolution event.
getFunctionName()
Determine the function name for a given API request.
protected
getFunctionName(string $entity, string $action, int $version) : string
Parameters
- $entity : string
-
API entity name.
- $action : string
-
API action name.
- $version : int
-
API version.
Return values
stringloadEntity()
Load/require all files related to an entity.
protected
loadEntity(string $entity, int $version) : mixed
This should not normally be called because it's does a file-system scan; it's only appropriate when introspection is really required (eg for "getActions").
Parameters
- $entity : string
-
API entity name.
- $version : int
-
API version.
resolve()
Look up the implementation for a given API request.
protected
resolve(array<string|int, mixed> $apiRequest) : array<string|int, mixed>
Parameters
- $apiRequest : array<string|int, mixed>
-
Array with keys:
- entity: string, required.
- action: string, required.
- params: array.
- version: scalar, required.
Return values
array<string|int, mixed> —Array with keys:
- function: callback (mixed)
- is_generic: boolean