Documentation

CRM_Core_ManagedEntities
in package

The ManagedEntities system allows modules to add records to the database declaratively. Those records will be automatically inserted, updated, deactivated, and deleted in tandem with their modules.

Table of Contents

Properties

$moduleIndex  : array<string|int, mixed>

Methods

__construct()  : mixed
getCleanupOptions()  : array<string|int, mixed>
Get clean up options.
reconcile()  : mixed
Identify any enabled/disabled modules. Add new entities, update existing entities, and remove orphaned (stale) entities.
revert()  : bool
Force-revert a record back to its original state.
scheduleReconciliation()  : mixed
Perform an asynchronous reconciliation when the transaction ends.
singleton()  : CRM_Core_ManagedEntities
Get an instance.
createModuleIndex()  : array<string|int, mixed>
createPlan()  : array<string|int, array<string|int, mixed>>
Builds $this->managedActions array
disableEntity()  : void
Update an entity which (a) is believed to exist and which (b) ought to be inactive.
getDeclarations()  : array<string|int, array<string|int, mixed>>
Load managed entity declarations.
insertNewEntity()  : mixed
Create a new entity (if policy allows).
isModuleDisabled()  : bool
Is the module disabled.
isModuleEnabled()  : bool
Is the module enabled.
isModuleRecognised()  : bool
Is the module recognised (as an enabled or disabled extension in the system).
onApiError()  : void
removeStaleEntity()  : mixed
Remove a stale entity (if policy allows).
validate()  : mixed
backfillDefaults()  : void
Backfill default values to restore record to a pristine state
filterPlanByAction()  : array<string|int, mixed>
Get the managed entities that fit the criteria.
isActivationSupported()  : bool
Determine if an entity supports APIv3-based activation/de-activation.
reconcileEntities()  : void
Take appropriate action on every managed entity.
updateExistingEntity()  : mixed
Update an entity which is believed to exist.

Properties

$moduleIndex

protected array<string|int, mixed> $moduleIndex

Array($status => array($name => CRM_Core_Module)).

Methods

__construct()

public __construct(array<string|int, mixed> $modules) : mixed
Parameters
$modules : array<string|int, mixed>

CRM_Core_Module.

getCleanupOptions()

Get clean up options.

public static getCleanupOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

reconcile()

Identify any enabled/disabled modules. Add new entities, update existing entities, and remove orphaned (stale) entities.

public reconcile([array<string|int, mixed> $modules = NULL ]) : mixed
Parameters
$modules : array<string|int, mixed> = NULL

Limits scope of reconciliation to specific module(s).

Tags
throws
CRM_Core_Exception

revert()

Force-revert a record back to its original state.

public revert(string $entityType, mixed $entityId) : bool
Parameters
$entityType : string
$entityId : mixed
Return values
bool

scheduleReconciliation()

Perform an asynchronous reconciliation when the transaction ends.

public static scheduleReconciliation([array<string|int, mixed>|null $modules = NULL ]) : mixed
Parameters
$modules : array<string|int, mixed>|null = NULL

createModuleIndex()

protected createModuleIndex(array<string|int, mixed> $modules) : array<string|int, mixed>
Parameters
$modules : array<string|int, mixed>

Array<CRM_Core_Module>.

Return values
array<string|int, mixed>

indexed by is_active,name

createPlan()

Builds $this->managedActions array

protected createPlan(array<string|int, mixed> $declarations[, array<string|int, mixed>|null $modules = NULL ]) : array<string|int, array<string|int, mixed>>
Parameters
$declarations : array<string|int, mixed>
$modules : array<string|int, mixed>|null = NULL
Return values
array<string|int, array<string|int, mixed>>

disableEntity()

Update an entity which (a) is believed to exist and which (b) ought to be inactive.

protected disableEntity(array<string|int, mixed> $item) : void
Parameters
$item : array<string|int, mixed>
Tags
throws
CRM_Core_Exception

getDeclarations()

Load managed entity declarations.

protected getDeclarations([array<string|int, mixed>|null $modules = NULL ]) : array<string|int, array<string|int, mixed>>

This picks it up from hooks and enabled components.

Parameters
$modules : array<string|int, mixed>|null = NULL

Limit reconciliation specified modules.

Return values
array<string|int, array<string|int, mixed>>

insertNewEntity()

Create a new entity (if policy allows).

protected insertNewEntity(array<string|int, mixed> $item) : mixed
Parameters
$item : array<string|int, mixed>

Entity specification (per hook_civicrm_managedEntities).

isModuleDisabled()

Is the module disabled.

protected isModuleDisabled(string $module) : bool
Parameters
$module : string
Return values
bool

isModuleEnabled()

Is the module enabled.

protected isModuleEnabled(string $module) : bool
Parameters
$module : string
Return values
bool

isModuleRecognised()

Is the module recognised (as an enabled or disabled extension in the system).

protected isModuleRecognised(string $module) : bool
Parameters
$module : string
Return values
bool

onApiError()

protected onApiError(string $moduleName, string $managedEntityName, string $actionName, string $errorMessage[, Throwable|null $exception = NULL ]) : void
Parameters
$moduleName : string
$managedEntityName : string
$actionName : string
$errorMessage : string
$exception : Throwable|null = NULL

removeStaleEntity()

Remove a stale entity (if policy allows).

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

validate()

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

backfillDefaults()

Backfill default values to restore record to a pristine state

private backfillDefaults(array<string|int, mixed> &$item) : void
Parameters
$item : array<string|int, mixed>

Managed APIv4 record

filterPlanByAction()

Get the managed entities that fit the criteria.

private filterPlanByAction(array<string|int, array<string|int, mixed>> $plan, string $action) : array<string|int, mixed>
Parameters
$plan : array<string|int, array<string|int, mixed>>
$action : string
Return values
array<string|int, mixed>

isActivationSupported()

Determine if an entity supports APIv3-based activation/de-activation.

private isActivationSupported(string $entity_type) : bool
Parameters
$entity_type : string
Tags
throws
CRM_Core_Exception
Return values
bool

reconcileEntities()

Take appropriate action on every managed entity.

private reconcileEntities(array<string|int, array<string|int, mixed>> $plan) : void
Parameters
$plan : array<string|int, array<string|int, mixed>>

updateExistingEntity()

Update an entity which is believed to exist.

private updateExistingEntity(array<string|int, mixed> $item) : mixed
Parameters
$item : array<string|int, mixed>

Entity specification (per hook_civicrm_managedEntities).


        
On this page

Search results