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. | |
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 | * | |
9e1bf145 | 24 | * @param MappingInterface $mapping |
9c8748cc | 25 | * The new mapping. |
4b350175 | 26 | * @return MappingRegisterEvent |
9c8748cc | 27 | */ |
9e1bf145 TO |
28 | public function register(MappingInterface $mapping) { |
29 | $this->mappings[$mapping->getId()] = $mapping; | |
9c8748cc TO |
30 | return $this; |
31 | } | |
32 | ||
33 | /** | |
34 | * @return array | |
9e1bf145 | 35 | * Array(scalar $id => MappingInterface $mapping). |
9c8748cc TO |
36 | */ |
37 | public function getMappings() { | |
46f5566c | 38 | ksort($this->mappings); |
9c8748cc TO |
39 | return $this->mappings; |
40 | } | |
41 | ||
42 | } |