Merge pull request #24109 from yashodha/reports_improvements
[civicrm-core.git] / Civi / Core / HookInterface.php
CommitLineData
ee44263e
CW
1<?php
2
3namespace Civi\Core;
4
5/**
6 * Interface HookInterface
7 * @package Civi\Core
8 *
9 * This interface allows CRM_BAO classes to subscribe to hooks.
10 * Simply create an eponymous hook function (e.g. `hook_civicrm_post()`).
11 *
12 * ```
13 * class CRM_Foo_BAO_Bar implements \Civi\Core\HookInterface {
14 * public function hook_civicrm_post($op, $objectName, $objectId, &$objectRef) {
15 * echo "Running hook_civicrm_post\n";
16 * }
17 * }
18 * ```
19 *
20 * Similarly, to subscribe using Symfony-style listeners, create function with the 'on_' prefix:
21 *
22 * ```
23 * class CRM_Foo_BAO_Bar implements \Civi\Core\HookInterface {
24 * public function on_civi_api_authorize(AuthorizeEvent $e): void {
25 * echo "Running civi.api.authorize\n";
26 * }
27 * public function on_hook_civicrm_post(GenericHookEvent $e): void {
28 * echo "Running hook_civicrm_post\n";
29 * }
30 * }
31 * ```
32 *
33 * If you need more advanced registration abilities, consider using `Civi::dispatcher()`
34 * or `EventDispatcherInterface`.
35 *
36 * @see \Civi\Core\Event\EventScanner::findListeners
37 */
38interface HookInterface {
39}