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