Merge pull request #9302 from systopia/CRM-19639-2
[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 class MappingRegisterEvent extends Event {
14
15 /**
16 * @var array
17 * Array(scalar $id => Mapping $mapping).
18 */
19 protected $mappings = array();
20
21 /**
22 * Register a new mapping.
23 *
24 * @param MappingInterface $mapping
25 * The new mapping.
26 * @return MappingRegisterEvent
27 */
28 public function register(MappingInterface $mapping) {
29 $this->mappings[$mapping->getId()] = $mapping;
30 return $this;
31 }
32
33 /**
34 * @return array
35 * Array(scalar $id => MappingInterface $mapping).
36 */
37 public function getMappings() {
38 ksort($this->mappings);
39 return $this->mappings;
40 }
41
42 }