ExceptionEvent
extends Event
in package
Handle any exceptions that occur while processing an API request.
Event name: 'civi.api.exception'
Table of Contents
Properties
- $apiKernel : Kernel
- $apiProvider : ProviderInterface
- $apiRequest : AbstractAction|array<string|int, mixed>
- $hookFields : array<string|int, mixed>
- $hookFieldsFlip : array<string|int, mixed>
- $hookValues : array<string|int, mixed>
- $BLACKLIST : array<string|int, mixed>
- List of field names that are prohibited due to conflicts in the class-hierarchy.
- $exception : Exception
- $returnValues : mixed
- Some legacy hooks expect listener-functions to return a value.
Methods
- __construct() : mixed
- __get() : mixed
- __isset() : mixed
- __set() : mixed
- __unset() : mixed
- addReturnValues() : GenericHookEvent
- create() : GenericHookEvent
- Create a GenericHookEvent using key-value pairs.
- createOrdered() : GenericHookEvent
- Create a GenericHookEvent using ordered parameters.
- getActionName() : string
- getApiKernel() : Kernel
- Get api kernel.
- getApiProvider() : ProviderInterface
- getApiRequest() : AbstractAction|array<string|int, mixed>
- getApiRequestSig() : string
- Create a brief string identifying the entity/action. Useful for pithy matching/switching.
- getEntityName() : string
- getException() : Exception
- getHookValues() : array<string|int, mixed>
- getReturnValues() : mixed
- hasField() : bool
- Determine whether the hook supports the given field.
- setApiRequest() : static
- assertValidHookFields() : mixed
Properties
$apiKernel
protected
Kernel
$apiKernel
$apiProvider
protected
ProviderInterface
$apiProvider
The API provider responsible for executing the request.
$apiRequest
protected
AbstractAction|array<string|int, mixed>
$apiRequest
The full description of the API request.
Tags
$hookFields
protected
array<string|int, mixed>
$hookFields
Ex: array(0 => 'contactID', 1 => 'contentPlacement').
$hookFieldsFlip
protected
array<string|int, mixed>
$hookFieldsFlip
Ex: array('contactID' => 0, 'contentPlacement' => 1).
$hookValues
protected
array<string|int, mixed>
$hookValues
Ex: array(0 => &$contactID, 1 => &$contentPlacement).
$BLACKLIST
List of field names that are prohibited due to conflicts in the class-hierarchy.
private
static array<string|int, mixed>
$BLACKLIST
= ['name', 'dispatcher', 'propagationStopped', 'hookBlacklist', 'hookValues', 'hookFields', 'hookFieldsFlip']
$exception
private
Exception
$exception
$returnValues
Some legacy hooks expect listener-functions to return a value.
private
mixed
$returnValues
= []
OOP listeners may set the $returnValue.
This field is not recommended for use in new hooks. The return-value convention is not portable across different implementations of the hook system. Instead, it's more portable to provide an alterable, named field.
Methods
__construct()
public
__construct(Exception $exception, ProviderInterface $apiProvider, array<string|int, mixed> $apiRequest, Kernel $apiKernel) : mixed
Parameters
- $exception : Exception
-
The exception which arose while processing the API request.
- $apiProvider : ProviderInterface
-
The API provider responsible for executing the request.
- $apiRequest : array<string|int, mixed>
-
The full description of the API request.
- $apiKernel : Kernel
-
The kernel which fired the event.
__get()
public
& __get(mixed $name) : mixed
Parameters
- $name : mixed
Tags
__isset()
public
__isset(mixed $name) : mixed
Parameters
- $name : mixed
Tags
__set()
public
__set(mixed $name, mixed $value) : mixed
Parameters
- $name : mixed
- $value : mixed
Tags
__unset()
public
__unset(mixed $name) : mixed
Parameters
- $name : mixed
Tags
addReturnValues()
public
addReturnValues(mixed $fResult) : GenericHookEvent
Parameters
- $fResult : mixed
Return values
GenericHookEventcreate()
Create a GenericHookEvent using key-value pairs.
public
static create(array<string|int, mixed> $params) : GenericHookEvent
Parameters
- $params : array<string|int, mixed>
-
Ex: array('contactID' => &$contactID, 'contentPlacement' => &$contentPlacement).
Return values
GenericHookEventcreateOrdered()
Create a GenericHookEvent using ordered parameters.
public
static createOrdered(array<string|int, mixed> $hookFields, array<string|int, mixed> $hookValues) : GenericHookEvent
Parameters
- $hookFields : array<string|int, mixed>
-
Ex: array(0 => 'contactID', 1 => 'contentPlacement').
- $hookValues : array<string|int, mixed>
-
Ex: array(0 => &$contactID, 1 => &$contentPlacement).
Return values
GenericHookEventgetActionName()
public
getActionName() : string
Return values
string —Ex: 'create', 'update'
getApiKernel()
Get api kernel.
public
getApiKernel() : Kernel
Return values
KernelgetApiProvider()
public
getApiProvider() : ProviderInterface
Return values
ProviderInterfacegetApiRequest()
public
getApiRequest() : AbstractAction|array<string|int, mixed>
Return values
AbstractAction|array<string|int, mixed>getApiRequestSig()
Create a brief string identifying the entity/action. Useful for pithy matching/switching.
public
getApiRequestSig() : string
Ex: if ($e->getApiRequestSig() === '3.contact.get') { ... }
Return values
string —Ex: '3.contact.get'
getEntityName()
public
getEntityName() : string
Return values
string —Ex: 'Contact', 'Activity'
getException()
public
getException() : Exception
Return values
ExceptiongetHookValues()
public
getHookValues() : array<string|int, mixed>
Return values
array<string|int, mixed> —Ex: array(0 => &$contactID, 1 => &$contentPlacement).
getReturnValues()
public
getReturnValues() : mixed
hasField()
Determine whether the hook supports the given field.
public
hasField(string $name) : bool
The field may or may not be empty. Use isset() or empty() to check that.
Parameters
- $name : string
Return values
boolsetApiRequest()
protected
setApiRequest(AbstractAction|array<string|int, mixed> $apiRequest) : static
Parameters
- $apiRequest : AbstractAction|array<string|int, mixed>
-
The full description of the API request.
Return values
staticassertValidHookFields()
private
static assertValidHookFields(array<string|int, mixed> $fields) : mixed
Parameters
- $fields : array<string|int, mixed>
-
List of field names.