class CRM_Core_ManagedEntities

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.

Properties

protected array $moduleIndex
protected array $declarations

Methods

static array
getCleanupOptions()

Get clean up options.

singleton(bool $fresh = FALSE)

Get an instance.

static 
scheduleReconciliation()

Perform an asynchronous reconciliation when the transaction ends.

__construct(array $modules, array $declarations)

No description

array|NULL
get(string $moduleName, string $name)

Read a managed entity using APIv3.

reconcile()

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

reconcileEnabledModules()

For all enabled modules, add new entities, update existing entities, and remove orphaned (stale) entities.

reconcileEnabledModule( $module, array $todos)

For one enabled module, add new entities, update existing entities, and remove orphaned (stale) entities.

reconcileDisabledModules()

For all disabled modules, disable any managed entities.

reconcileUnknownModules()

Remove any orphaned (stale) entities that are linked to unknown modules.

insertNewEntity(array $todo)

Create a new entity.

updateExistingEntity(CRM_Core_DAO_Managed $dao, array $todo)

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

disableEntity(CRM_Core_DAO_Managed $dao)

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

removeStaleEntity(CRM_Core_DAO_Managed $dao)

Remove a stale entity (if policy allows).

array|null
getDeclarations()

Get declarations.

static array
createModuleIndex(array $modules)

No description

static array
createDeclarationIndex(array $moduleIndex, array $declarations)

No description

static string|bool
validate($declarations)

No description

static array
cleanDeclarations(array $declarations)

No description

onApiError(string $entity, string $action, array $params, array $result)

No description

Details

at line 15
static array getCleanupOptions()

Get clean up options.

Return Value

array

at line 41
static CRM_Core_ManagedEntities singleton(bool $fresh = FALSE)

Get an instance.

Parameters

bool $fresh

Return Value

CRM_Core_ManagedEntities

at line 52
static scheduleReconciliation()

Perform an asynchronous reconciliation when the transaction ends.

at line 69
__construct(array $modules, array $declarations)

Parameters

array $modules CRM_Core_Module.
array $declarations Per hook_civicrm_managed.

at line 90
array|NULL get(string $moduleName, string $name)

Read a managed entity using APIv3.

Parameters

string $moduleName The name of the module which declared entity.
string $name The symbolic name of the entity.

Return Value

array|NULL API representation, or NULL if the entity does not exist

at line 118
reconcile()

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

Exceptions

Exception

at line 133
reconcileEnabledModules()

For all enabled modules, add new entities, update existing entities, and remove orphaned (stale) entities.

Exceptions

Exception

at line 161
reconcileEnabledModule( $module, array $todos)

For one enabled module, add new entities, update existing entities, and remove orphaned (stale) entities.

Parameters

$module
array $todos List of entities currently declared by this module. array(string $name => array $entityDef).

at line 186
reconcileDisabledModules()

For all disabled modules, disable any managed entities.

at line 205
reconcileUnknownModules()

Remove any orphaned (stale) entities that are linked to unknown modules.

at line 231
insertNewEntity(array $todo)

Create a new entity.

Parameters

array $todo Entity specification (per hook_civicrm_managedEntities).

at line 253
updateExistingEntity(CRM_Core_DAO_Managed $dao, array $todo)

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

Parameters

CRM_Core_DAO_Managed $dao
array $todo Entity specification (per hook_civicrm_managedEntities).

at line 281
disableEntity(CRM_Core_DAO_Managed $dao)

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

Parameters

CRM_Core_DAO_Managed $dao

at line 303
removeStaleEntity(CRM_Core_DAO_Managed $dao)

Remove a stale entity (if policy allows).

Parameters

CRM_Core_DAO_Managed $dao

Exceptions

Exception

at line 356
array|null getDeclarations()

Get declarations.

Return Value

array|null

at line 376
static protected array createModuleIndex(array $modules)

Parameters

array $modules Array.

Return Value

array indexed by is_active,name

at line 391
static protected array createDeclarationIndex(array $moduleIndex, array $declarations)

Parameters

array $moduleIndex
array $declarations

Return Value

array indexed by module,name

at line 414
static protected string|bool validate($declarations)

Parameters

$declarations

Return Value

string|bool string on error, or FALSE

at line 432
static protected array cleanDeclarations(array $declarations)

Parameters

array $declarations

Return Value

array

at line 449
protected onApiError(string $entity, string $action, array $params, array $result)

Parameters

string $entity
string $action
array $params
array $result

Exceptions

Exception