1 | <?php |
||
19 | class Sender implements EventManagerAwareInterface |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * @var TransportInterface |
||
24 | */ |
||
25 | protected $transport; |
||
26 | |||
27 | /** |
||
28 | * @var EventManagerInterface |
||
29 | */ |
||
30 | protected $eventManager; |
||
31 | |||
32 | /** |
||
33 | * Class constructor |
||
34 | * |
||
35 | * @param TransportInterface $transport |
||
36 | */ |
||
37 | 5 | public function __construct(TransportInterface $transport) |
|
41 | |||
42 | /** |
||
43 | * Inject an EventManager instance |
||
44 | * |
||
45 | * @param EventManagerInterface $eventManager |
||
46 | * @return self |
||
47 | */ |
||
48 | 3 | public function setEventManager(EventManagerInterface $eventManager) |
|
54 | |||
55 | /** |
||
56 | * Retrieve the event manager |
||
57 | * |
||
58 | * Lazy-loads an EventManager instance if none registered. |
||
59 | * |
||
60 | * @return EventManagerInterface |
||
61 | */ |
||
62 | 5 | public function getEventManager() |
|
63 | { |
||
64 | 5 | if (null === $this->eventManager) { |
|
65 | 3 | $this->eventManager = new EventManager(); |
|
66 | } |
||
67 | |||
68 | 5 | return $this->eventManager; |
|
69 | } |
||
70 | |||
71 | /** |
||
72 | * Create and return event used by compose and send methods |
||
73 | * |
||
74 | * @return SenderEvent |
||
75 | */ |
||
76 | 2 | protected function getEvent() |
|
83 | |||
84 | /** |
||
85 | * Send message |
||
86 | * |
||
87 | * @param Message $message |
||
88 | * @return void |
||
89 | */ |
||
90 | 2 | public function send(Message $message) |
|
101 | } |
||
102 |