Documentation

Kernel
in package

Tags
copyright

CiviCRM LLC https://civicrm.org/licensing

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

Methods

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
throws
UnauthorizedException

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
throws
CRM_Core_Exception
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
throws
CRM_Core_Exception
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
throws
CRM_Core_Exception
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
throws
CRM_Core_Exception
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>

getEntityNames()

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.

resolve()

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
throws
NotImplementedException
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
throws
CRM_Core_Exception
see
runSafe
Return values
array<string|int, mixed>|int

runAuthorize()

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
throws
Exception
Return values
bool

TRUE if authorization would succeed.

runSafe()

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
throws
CRM_Core_Exception
Return values
array<string|int, mixed>|int

validate()

protected validate(array<string|int, mixed> $apiRequest) : mixed
Parameters
$apiRequest : array<string|int, mixed>
Tags
throws
CRM_Core_Exception

        
On this page

Search results