1 | <?php |
||
12 | abstract class EventBase extends Event |
||
13 | { |
||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $eventName; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $payload; |
||
23 | |||
24 | /** |
||
25 | * @var ModelBase |
||
26 | */ |
||
27 | protected $model; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $delivery; |
||
33 | |||
34 | /** |
||
35 | * EventBase constructor. |
||
36 | * @param string $eventName |
||
37 | * @param string $payload |
||
38 | * @param string $delivery |
||
39 | */ |
||
40 | public function __construct($eventName, $payload, $delivery = null) |
||
41 | { |
||
42 | $this->eventName = $eventName; |
||
43 | $this->payload = $payload; |
||
44 | $this->delivery = $delivery; |
||
45 | |||
46 | $payload = json_decode($this->payload, true); |
||
47 | $className = $this->getClassModel(); |
||
48 | $this->model = new $className($payload); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return string |
||
53 | */ |
||
54 | public function getEventName() |
||
58 | |||
59 | /** |
||
60 | * @return string |
||
61 | */ |
||
62 | public function getPayload() |
||
66 | |||
67 | /** |
||
68 | * @return ModelBase |
||
69 | */ |
||
70 | public function getModel() |
||
74 | |||
75 | /** |
||
76 | * @return string |
||
77 | */ |
||
78 | abstract protected function getClassModel(); |
||
79 | } |
||
80 |