1 | <?php |
||
13 | class CallbackInvoker implements LifeCycleCallback, LifeCycleCallbackInvoker |
||
14 | { |
||
15 | /** |
||
16 | * @var Closure |
||
17 | */ |
||
18 | protected $onComplete; |
||
19 | |||
20 | /** |
||
21 | * @var Closure |
||
22 | */ |
||
23 | protected $onEachSent; |
||
24 | |||
25 | /** |
||
26 | * @var Closure |
||
27 | */ |
||
28 | protected $onError; |
||
29 | |||
30 | /** |
||
31 | * @inheritdoc |
||
32 | */ |
||
33 | 7 | public function callOnComplete(MessageQueue $param) |
|
39 | |||
40 | /** |
||
41 | * @inheritdoc |
||
42 | */ |
||
43 | 6 | public function callOnEachSent(MessageInterface $message, $feedBack = null) |
|
49 | |||
50 | /** |
||
51 | * @inheritdoc |
||
52 | */ |
||
53 | 2 | public function callOnError(MessageInterface $message, PushNotificationException $exc) |
|
54 | { |
||
55 | 2 | if (isset($this->onError)) { |
|
56 | 1 | call_user_func_array($this->onError, array($message, $exc)); |
|
57 | 1 | } else { |
|
58 | 1 | throw $exc; |
|
59 | } |
||
60 | 1 | } |
|
61 | |||
62 | /** |
||
63 | * @inheritdoc |
||
64 | */ |
||
65 | 3 | public function onComplete(\Closure $callback) |
|
69 | |||
70 | /** |
||
71 | * @inheritdoc |
||
72 | */ |
||
73 | 5 | public function onEachSent(\Closure $callback) |
|
77 | |||
78 | /** |
||
79 | * @inheritdoc |
||
80 | */ |
||
81 | 1 | public function onError(Closure $callback) |
|
82 | { |
||
83 | 1 | $this->onError = $callback; |
|
84 | 1 | } |
|
85 | |||
86 | /** |
||
87 | * @inheritdoc |
||
88 | */ |
||
89 | 3 | public function detach() |
|
93 | } |