Skip to content

hook_civicrm_entityTypes

Summary

Lowest-level hook for modifying the list of system entities.

Advanced Use Only

Most extensions need not implement this hook directly, as entities can be defined via .entityType.php files in conjunction with the entity-types-php mixin, which will automatically read those files and pass their contents to this hook.

Notes

  • See this tutorial for a more complete description of creating new types of entities.
  • The entity-type metadata is important to the system setup. The hook is therefore very sensitive about timing -- depending on how the hook-listener is declared, it may or may not work reliably.

    Declaration Comments
    🟢 Extension style (main-file) This style is generally supported across all versions/use-cases.
    🟡 Drupal style, WordPress style, or Joomla style This style should work if the site consistently bootstraps the CMS before CiviCRM. It is not tested for extern/*.php-style entry-points.
    🟡 Symfony style (after v5.45) This works when using Civi::dispatcher()->addListener() in a mixin.
    Other listener notations (such as EventSubscriberInterface and HookInterface) may be unreliable.
    🔴 Symfony style (before v5.45) Unlikely to work.

Definition

hook_civicrm_entityTypes(&$entityTypes)

Parameters

  • $entityTypes (array[]) Each item is an entity definition (array). They are keyed by the canonical name of the entity (e.g. Activity, Contact, Participant). Note: Older versions of CiviCRM used the DAO classname as key (e.g. 'CRM_Activity_DAO_Activity').

Each entity definition array must contain at least the keys: - 'name' (string) - Canonical name of entity (same as array key of the item). - 'module' (string) - Full name of extension declaring the entity.

For all possible values in the entity definition array, see the section on CiviCRM Entities.

Returns

  • void