Kernel
in package
Tags
Table of Contents
Properties
- $apiProviders : array<string|int, ProviderInterface>
- $dispatcher : CiviEventDispatcherInterface
Methods
- __construct() : mixed
- authorize() : mixed
- Determine if the API request is allowed (under current policy)
- boot() : mixed
- Bootstrap - Load basic dependencies and sanity-check inputs.
- createError() : array<string|int, mixed>
- formatApiException() : array<string|int, mixed>
- formatException() : array<string|int, mixed>
- formatPearException() : array<string|int, mixed>
- formatResult() : mixed
- getActionNames() : array<string|int, string>
- getApiProviders() : array<string|int, ProviderInterface>
- getDispatcher() : CiviEventDispatcherInterface
- getEntityNames() : array<string|int, string>
- prepare() : array<string|int, mixed>
- Allow third-party code to manipulate the API request before execution.
- registerApiProvider() : Kernel
- resolve() : array<string|int, mixed>
- Determine which, if any, service will execute the API request.
- respond() : mixed
- Allow third-party code to manipulate the API response after execution.
- run() : array<string|int, mixed>|int
- runAuthorize() : bool
- Determine if a hypothetical API call would be authorized.
- runRequest() : array<string|int, mixed>|Result
- Execute an API v3 or v4 request.
- runSafe() : array<string|int, mixed>|int
- Parse and execute an API request. Any errors will be converted to normal format.
- setApiProviders() : Kernel
- setDispatcher() : Kernel
- validate() : mixed
Properties
$apiProviders
protected
array<string|int, ProviderInterface>
$apiProviders
$dispatcher
protected
CiviEventDispatcherInterface
$dispatcher
Methods
__construct()
public
__construct(CiviEventDispatcherInterface $dispatcher[, array<string|int, ProviderInterface> $apiProviders = [] ]) : mixed
Parameters
- $dispatcher : CiviEventDispatcherInterface
- $apiProviders : array<string|int, ProviderInterface> = []
authorize()
Determine if the API request is allowed (under current policy)
public
authorize(ProviderInterface $apiProvider, array<string|int, mixed> $apiRequest) : mixed
Parameters
- $apiProvider : ProviderInterface
-
The API provider responsible for executing the request.
- $apiRequest : array<string|int, mixed>
-
The full description of the API request.
Tags
boot()
Bootstrap - Load basic dependencies and sanity-check inputs.
public
boot(AbstractAction|array<string|int, mixed> $apiRequest) : mixed
Parameters
- $apiRequest : AbstractAction|array<string|int, mixed>
Tags
createError()
public
createError(string $msg, array<string|int, mixed> $data, array<string|int, mixed> $apiRequest) : array<string|int, mixed>
Parameters
- $msg : string
-
Descriptive error message.
- $data : array<string|int, mixed>
-
Error data.
- $apiRequest : array<string|int, mixed>
-
The full description of the API request.
Tags
Return values
array<string|int, mixed>formatApiException()
public
formatApiException(CRM_Core_Exception $e, array<string|int, mixed> $apiRequest) : array<string|int, mixed>
Parameters
- $e : CRM_Core_Exception
-
An unhandled exception.
- $apiRequest : array<string|int, mixed>
-
The full description of the API request.
Tags
Return values
array<string|int, mixed> —(API response)
formatException()
public
formatException(Exception $e, array<string|int, mixed> $apiRequest) : array<string|int, mixed>
Parameters
- $e : Exception
-
An unhandled exception.
- $apiRequest : array<string|int, mixed>
-
The full description of the API request.
Tags
Return values
array<string|int, mixed> —API response.
formatPearException()
public
formatPearException(PEAR_Exception $e, array<string|int, mixed> $apiRequest) : array<string|int, mixed>
Parameters
- $e : PEAR_Exception
-
An unhandled exception.
- $apiRequest : array<string|int, mixed>
-
The full description of the API request.
Tags
Return values
array<string|int, mixed> —API response.
formatResult()
public
formatResult(array<string|int, mixed> $apiRequest, array<string|int, mixed> $result) : mixed
Parameters
- $apiRequest : array<string|int, mixed>
-
The full description of the API request.
- $result : array<string|int, mixed>
-
The response to return to the client.
getActionNames()
public
getActionNames(int $version, string $entity) : array<string|int, string>
Parameters
- $version : int
-
API version.
- $entity : string
-
API entity.
Return values
array<string|int, string>getApiProviders()
public
getApiProviders() : array<string|int, ProviderInterface>
Return values
array<string|int, ProviderInterface>getDispatcher()
public
getDispatcher() : CiviEventDispatcherInterface
Return values
CiviEventDispatcherInterfacegetEntityNames()
public
getEntityNames(int $version) : array<string|int, string>
Parameters
- $version : int
-
API version.
Return values
array<string|int, string>prepare()
Allow third-party code to manipulate the API request before execution.
public
prepare(ProviderInterface $apiProvider, array<string|int, mixed> $apiRequest) : array<string|int, mixed>
Parameters
- $apiProvider : ProviderInterface
-
The API provider responsible for executing the request.
- $apiRequest : array<string|int, mixed>
-
The full description of the API request.
Return values
array<string|int, mixed> —[0 => ProviderInterface $provider, 1 => array $apiRequest] The revised API request.
registerApiProvider()
public
registerApiProvider(ProviderInterface $apiProvider) : Kernel
Parameters
- $apiProvider : ProviderInterface
-
The API provider responsible for executing the request.
Return values
Kernelresolve()
Determine which, if any, service will execute the API request.
public
resolve(array<string|int, mixed> $apiRequest) : array<string|int, mixed>
Parameters
- $apiRequest : array<string|int, mixed>
-
The full description of the API request.
Tags
Return values
array<string|int, mixed> —A tuple with the provider-object and a revised apiRequest. Array(0 => ProviderInterface, 1 => array $apiRequest).
respond()
Allow third-party code to manipulate the API response after execution.
public
respond(ProviderInterface $apiProvider, array<string|int, mixed> $apiRequest, array<string|int, mixed> $result) : mixed
Parameters
- $apiProvider : ProviderInterface
-
The API provider responsible for executing the request.
- $apiRequest : array<string|int, mixed>
-
The full description of the API request.
- $result : array<string|int, mixed>
-
The response to return to the client.
Return values
mixed —The revised $result.
run()
public
run(string $entity, string $action, array<string|int, mixed> $params) : array<string|int, mixed>|int
Parameters
- $entity : string
-
Name of entity: e.g. Contact, Activity, Event
- $action : string
-
Name of action: e.g. create, get, delete
- $params : array<string|int, mixed>
-
Array to be passed to API function.
Tags
Return values
array<string|int, mixed>|intrunAuthorize()
Determine if a hypothetical API call would be authorized.
public
runAuthorize(string $entity, string $action, array<string|int, mixed> $params) : bool
Parameters
- $entity : string
-
Type of entities to deal with.
- $action : string
-
Create, get, delete or some special action name.
- $params : array<string|int, mixed>
-
Array to be passed to function.
Tags
Return values
bool —TRUE if authorization would succeed.
runRequest()
Execute an API v3 or v4 request.
public
runRequest(array<string|int, mixed>|AbstractAction $apiRequest) : array<string|int, mixed>|Result
The request must be in canonical format. Exceptions will be propagated out.
Parameters
- $apiRequest : array<string|int, mixed>|AbstractAction
Tags
Return values
array<string|int, mixed>|ResultrunSafe()
Parse and execute an API request. Any errors will be converted to normal format.
public
runSafe(string $entity, string $action, array<string|int, mixed> $params) : array<string|int, mixed>|int
Parameters
- $entity : string
-
Name of entity: e.g. Contact, Activity, Event
- $action : string
-
Name of action: e.g. create, get, delete
- $params : array<string|int, mixed>
-
Array to be passed to API function.
Tags
Return values
array<string|int, mixed>|intsetApiProviders()
public
setApiProviders(array<string|int, ProviderInterface> $apiProviders) : Kernel
Parameters
- $apiProviders : array<string|int, ProviderInterface>
Return values
KernelsetDispatcher()
public
setDispatcher(CiviEventDispatcherInterface $dispatcher) : Kernel
Parameters
- $dispatcher : CiviEventDispatcherInterface
-
The event dispatcher which receives kernel events.
Return values
Kernelvalidate()
protected
validate(array<string|int, mixed> $apiRequest) : mixed
Parameters
- $apiRequest : array<string|int, mixed>