Merge pull request #17348 from eileenmcnaughton/payex
[civicrm-core.git] / Civi / Core / Event / PreEvent.php
CommitLineData
fd901044
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
41498ac5 4 | Copyright CiviCRM LLC. All rights reserved. |
fd901044 5 | |
41498ac5
TO
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 |
fd901044 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
fd901044
TO
11
12namespace Civi\Core\Event;
13
14/**
15 * Class AuthorizeEvent
16 * @package Civi\API\Event
17 */
c73e3098
TO
18class PreEvent 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\PreEvent $event
26 */
27 public static function dispatchSubevent(PreEvent $event) {
4162ab6f 28 \Civi::dispatcher()->dispatch("hook_civicrm_pre::" . $event->entity, $event);
c73e3098 29 }
fd901044
TO
30
31 /**
8d0a3eb6
TO
32 * One of: 'create'|'edit'|'delete'
33 *
34 * @var string
fd901044
TO
35 */
36 public $action;
37
38 /**
39 * @var string
40 */
41 public $entity;
42
43 /**
e97c66ff 44 * @var int|null
fd901044
TO
45 */
46 public $id;
47
48 /**
49 * @var array
50 */
51 public $params;
52
7fe37828 53 /**
e97c66ff 54 * Class constructor.
55 *
56 * @param string $action
57 * @param string $entity
58 * @param int $id
59 * @param array $params
7fe37828 60 */
c73e3098 61 public function __construct($action, $entity, $id, &$params) {
fd901044
TO
62 $this->action = $action;
63 $this->entity = $entity;
64 $this->id = $id;
c73e3098
TO
65 $this->params = &$params;
66 }
67
68 /**
69 * @inheritDoc
70 */
71 public function getHookValues() {
c64f69d9 72 return [$this->action, $this->entity, $this->id, &$this->params];
fd901044 73 }
96025800 74
fd901044 75}