Merge pull request #17163 from jitendrapurohit/core-1731
[civicrm-core.git] / Civi / ActionSchedule / Event / MappingRegisterEvent.php
1 <?php
2 namespace Civi\ActionSchedule\Event;
3
4 use Civi\ActionSchedule\MappingInterface;
5 use Symfony\Component\EventDispatcher\Event;
6
7 /**
8 * Class ActionScheduleEvent
9 * @package Civi\ActionSchedule\Event
10 *
11 * Register any available mappings.
12 *
13 * Event name: 'civi.actionSchedule.getMappings'
14 */
15 class MappingRegisterEvent extends Event {
16
17 /**
18 * @var array
19 * Array(scalar $id => Mapping $mapping).
20 */
21 protected $mappings = [];
22
23 /**
24 * Register a new mapping.
25 *
26 * @param \Civi\ActionSchedule\MappingInterface $mapping
27 * The new mapping.
28 * @return MappingRegisterEvent
29 */
30 public function register(MappingInterface $mapping) {
31 $this->mappings[$mapping->getId()] = $mapping;
32 return $this;
33 }
34
35 /**
36 * @return array
37 * Array(scalar $id => MappingInterface $mapping).
38 */
39 public function getMappings() {
40 ksort($this->mappings);
41 return $this->mappings;
42 }
43
44 }