Merge pull request #15759 from tunbola/active-option-values-for-custom-group
[civicrm-core.git] / Civi / Core / Event / PostEvent.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 namespace Civi\Core\Event;
13
14 /**
15 * Class AuthorizeEvent
16 * @package Civi\API\Event
17 */
18 class PostEvent extends GenericHookEvent {
19
20 /**
21 * This adapter automatically emits a narrower event.
22 *
23 * For example, `hook_civicrm_pre(Contact, ...)` will also dispatch `hook_civicrm_pre::Contact`.
24 *
25 * @param \Civi\Core\Event\PostEvent $event
26 */
27 public static function dispatchSubevent(PostEvent $event) {
28 \Civi::service('dispatcher')->dispatch("hook_civicrm_post::" . $event->entity, $event);
29 }
30
31 /**
32 * @var string 'create'|'edit'|'delete' etc
33 */
34 public $action;
35
36 /**
37 * @var string
38 */
39 public $entity;
40
41 /**
42 * @var int|null
43 */
44 public $id;
45
46 /**
47 * @var Object
48 */
49 public $object;
50
51 /**
52 * Class constructor
53 *
54 * @param string $action
55 * @param string $entity
56 * @param int $id
57 * @param object $object
58 */
59 public function __construct($action, $entity, $id, &$object) {
60 $this->action = $action;
61 $this->entity = $entity;
62 $this->id = $id;
63 $this->object = &$object;
64 }
65
66 /**
67 * @inheritDoc
68 */
69 public function getHookValues() {
70 return [$this->action, $this->entity, $this->id, &$this->object];
71 }
72
73 }