class CiviEventInspector

Class CiviEventInspector

The event inspector is a development tool which provides metadata about events. It can be used for code-generators and documentation-generators.

Properties

protected array $eventDefs

Methods

static 
findBuiltInEvents( $e)

Register the default hooks defined by 'CRM_Utils_Hook'.

build(bool $force = FALSE)

Perform a scan to identify/describe all events.

array
getAll()

Get a list of all events.

array
find(string $regex)

Find any events that match a pattern.

array
get(string $name)

Get the definition of one event.

bool
validate($eventDef)

No description

add(array $eventDef)

Add a new event definition.

addEventClass(string $event, string $className)

Scan a Symfony event class for metadata, and add it.

addStaticStubs(string $className, string $prefix, null|callable $filter = NULL)

Scan a class for hook stubs, and add all of them.

Details

at line 35
static findBuiltInEvents( $e)

Register the default hooks defined by 'CRM_Utils_Hook'.

Parameters

$e

See also

\CRM_Utils_Hook::eventDefs()

at line 57
CiviEventInspector build(bool $force = FALSE)

Perform a scan to identify/describe all events.

Parameters

bool $force

Return Value

CiviEventInspector

at line 73
array getAll()

Get a list of all events.

Return Value

array Array(string $name => array $eventDef). Ex: $result['hook_civicrm_foo']['description_html'] = 'Hello world';

at line 86
array find(string $regex)

Find any events that match a pattern.

Parameters

string $regex

Return Value

array Array(string $name => array $eventDef). Ex: $result['hook_civicrm_foo']['description_html'] = 'Hello world';

at line 101
array get(string $name)

Get the definition of one event.

Parameters

string $name Ex: 'hook_civicrm_alterSettingsMetaData'.

Return Value

array Ex: $result['description_html'] = 'Hello world';

at line 111
bool validate($eventDef)

Parameters

$eventDef

Return Value

bool TRUE if valid.

at line 135
CiviEventInspector add(array $eventDef)

Add a new event definition.

Parameters

array $eventDef

Return Value

CiviEventInspector

at line 169
CiviEventInspector addEventClass(string $event, string $className)

Scan a Symfony event class for metadata, and add it.

Parameters

string $event Ex: 'civi.api.authorize'.
string $className Ex: 'Civi\API\Event\AuthorizeEvent'.

Return Value

CiviEventInspector

at line 190
CiviEventInspector addStaticStubs(string $className, string $prefix, null|callable $filter = NULL)

Scan a class for hook stubs, and add all of them.

Parameters

string $className The name of a class which contains static stub functions. Ex: 'CRM_Utils_Hook'.
string $prefix A prefix to apply to all hook names. Ex: 'hook_civicrm_'.
null|callable $filter An optional function to filter/rewrite the metadata for each hook.

Return Value

CiviEventInspector