1 | <?php |
||
30 | class Dispatcher implements LoggerAwareInterface |
||
31 | { |
||
32 | /** |
||
33 | * @var Application |
||
34 | */ |
||
35 | private $application; |
||
36 | |||
37 | /** |
||
38 | * @var NotificationBuilder |
||
39 | */ |
||
40 | private $notificationBuilder; |
||
41 | |||
42 | /** |
||
43 | * @var array |
||
44 | */ |
||
45 | private $connectionPool; |
||
46 | |||
47 | /** |
||
48 | * @var ServiceClientFactory |
||
49 | */ |
||
50 | private $clientFactory; |
||
51 | |||
52 | /** |
||
53 | * @var \ArrayIterator |
||
54 | */ |
||
55 | private $responseCollection; |
||
56 | |||
57 | /** |
||
58 | * @var LoggerInterface |
||
59 | */ |
||
60 | private $logger; |
||
61 | |||
62 | /** |
||
63 | * @param Application $application |
||
64 | * @param ServiceClientFactory $clientFactory |
||
65 | * @param NotificationBuilder $notificationBuilder |
||
66 | */ |
||
67 | public function __construct( |
||
78 | |||
79 | /** |
||
80 | * @param LoggerInterface $logger |
||
81 | * @return $this |
||
82 | */ |
||
83 | public function setLogger(LoggerInterface $logger) |
||
88 | |||
89 | /** |
||
90 | * @param bool $isDevelopment |
||
91 | * @return $this |
||
92 | */ |
||
93 | public function setDevelopmentMode($isDevelopment) |
||
98 | |||
99 | /** |
||
100 | * Returns credentials for notification service |
||
101 | * |
||
102 | * @param string $serviceName |
||
103 | * @return array |
||
104 | */ |
||
105 | private function getServiceCredentials($serviceName) |
||
109 | |||
110 | /** |
||
111 | * Gets a service client connection by service name |
||
112 | * |
||
113 | * @param string $serviceName |
||
114 | * @return ServiceClientInterface |
||
115 | */ |
||
116 | public function getConnection($serviceName) |
||
124 | |||
125 | /** |
||
126 | * Initialize service client connection by service name |
||
127 | * |
||
128 | * @param string $serviceName |
||
129 | * @return $this |
||
130 | */ |
||
131 | public function initConnection($serviceName) |
||
139 | |||
140 | public function addResponse($response) |
||
146 | |||
147 | /** |
||
148 | * Tries to dispatch all messages to notification service |
||
149 | * |
||
150 | * @return bool |
||
151 | * @throws Zbox\UnifiedPush\Exception\ClientException |
||
152 | * @throws Zbox\UnifiedPush\Exception\RuntimeException |
||
153 | * @throws \Exception |
||
154 | */ |
||
155 | public function dispatch() |
||
189 | |||
190 | /** |
||
191 | * Tries to connect and load feedback data |
||
192 | * |
||
193 | * @return $this |
||
194 | * @throws RuntimeException |
||
195 | * @throws \Exception |
||
196 | */ |
||
197 | public function loadFeedback() |
||
226 | |||
227 | /** |
||
228 | * Creates a feedback service connection |
||
229 | * |
||
230 | * @param string $serviceName |
||
231 | * @return ServiceClientInterface |
||
232 | */ |
||
233 | private function createFeedbackConnection($serviceName) |
||
238 | |||
239 | /** |
||
240 | * Tries to connect and send a message to notification service |
||
241 | * |
||
242 | * @return bool |
||
243 | * @throws Zbox\UnifiedPush\Exception\InvalidRecipientException |
||
244 | * @throws Zbox\UnifiedPush\Exception\DispatchMessageException |
||
245 | * @throws Zbox\UnifiedPush\Exception\MalformedNotificationException |
||
246 | */ |
||
247 | private function sendNotifications() |
||
275 | } |
||
276 |