Skip to content
Snippets Groups Projects
  • totten's avatar
    42ccedc7
    Civi::dispatcher() - Close loopholes that occur during early boot · 42ccedc7
    totten authored
    Before
    ------
    
    * The event-dispatcher is fully instantiated as a container service (`Container::createEventDispatcher()`).
    * It is not possible to add listeners to `Civi::dispatcher()` before the container is instantiated.
    * It is not possible to add listeners to `Civi::dispatcher()` in the top-level logic of an extension file (`myext.php`)
    * There is a distinction between "pre-boot" hooks (`hook_civicrm_container` or `hook_civicrm_entityType`) and
      normal hooks. Pre-boot hooks do not work with `Civi::dispatcher()`.
    
    After
    -----
    
    * The event-dispatcher is instantiated as boot service (ie very early during bootstrap).
    * To preserve compatibility (with `RegisterListenersPass`, with any downstream modifications of `createEventDispatcher`,
      and with any dependency-injection) the event-dispatcher will still use `createEventDispatcher()` for extra
      intialization.
    * It is possible to add listeners to `Civi::dispatcher()` in several more places, e.g.
      at the top-level of an extension's `.php` file and in `CRM_Utils_System_*::initialize()`
    * There is no distinction between "preboot" hooks and normal hooks. `Civi::dispatcher()` can
      register listeners for all hooks.
    * To ensure that we do not accidentally re-create "preboot" hooks, this patch enables a
      "dispatch policy" => if any hook fires too early, it will throw an exception.
    42ccedc7
    History
    Civi::dispatcher() - Close loopholes that occur during early boot
    totten authored
    Before
    ------
    
    * The event-dispatcher is fully instantiated as a container service (`Container::createEventDispatcher()`).
    * It is not possible to add listeners to `Civi::dispatcher()` before the container is instantiated.
    * It is not possible to add listeners to `Civi::dispatcher()` in the top-level logic of an extension file (`myext.php`)
    * There is a distinction between "pre-boot" hooks (`hook_civicrm_container` or `hook_civicrm_entityType`) and
      normal hooks. Pre-boot hooks do not work with `Civi::dispatcher()`.
    
    After
    -----
    
    * The event-dispatcher is instantiated as boot service (ie very early during bootstrap).
    * To preserve compatibility (with `RegisterListenersPass`, with any downstream modifications of `createEventDispatcher`,
      and with any dependency-injection) the event-dispatcher will still use `createEventDispatcher()` for extra
      intialization.
    * It is possible to add listeners to `Civi::dispatcher()` in several more places, e.g.
      at the top-level of an extension's `.php` file and in `CRM_Utils_System_*::initialize()`
    * There is no distinction between "preboot" hooks and normal hooks. `Civi::dispatcher()` can
      register listeners for all hooks.
    * To ensure that we do not accidentally re-create "preboot" hooks, this patch enables a
      "dispatch policy" => if any hook fires too early, it will throw an exception.
Civi.php 4.59 KiB