Skip to content
Snippets Groups Projects
Commit 42ccedc7 authored by totten's avatar totten
Browse files

Civi::dispatcher() - Close loopholes that occur during early boot

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.
parent a7718acb
Branches
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment