1 | <?php |
||
34 | abstract class AbstractProvider implements ProviderInterface |
||
35 | { |
||
36 | /** |
||
37 | * QPush Queue Name |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $name; |
||
42 | |||
43 | /** |
||
44 | * QPush Queue Options |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $options; |
||
49 | |||
50 | /** |
||
51 | * Doctrine APC Cache Driver |
||
52 | * |
||
53 | * @var Cache |
||
54 | */ |
||
55 | protected $cache; |
||
56 | |||
57 | /** |
||
58 | * Monolog Logger |
||
59 | * |
||
60 | * @var Logger |
||
61 | */ |
||
62 | protected $logger; |
||
63 | |||
64 | /** |
||
65 | * {@inheritDoc} |
||
66 | */ |
||
67 | 3 | public function getName() |
|
71 | |||
72 | /** |
||
73 | * {@inheritDoc} |
||
74 | */ |
||
75 | 17 | public function getNameWithPrefix() |
|
76 | { |
||
77 | 17 | if (!empty($this->options['queue_name'])) { |
|
78 | 1 | return $this->options['queue_name']; |
|
79 | } |
||
80 | |||
81 | 16 | return sprintf("%s_%s", self::QPUSH_PREFIX, $this->name); |
|
82 | } |
||
83 | |||
84 | /** |
||
85 | * {@inheritDoc} |
||
86 | */ |
||
87 | 1 | public function getOptions() |
|
91 | |||
92 | /** |
||
93 | * {@inheritDoc} |
||
94 | */ |
||
95 | 1 | public function getCache() |
|
99 | |||
100 | /** |
||
101 | * {@inheritDoc} |
||
102 | */ |
||
103 | 1 | public function getlogger() |
|
107 | |||
108 | /** |
||
109 | * {@inheritDoc} |
||
110 | */ |
||
111 | 20 | public function log($level, $message, array $context = []) |
|
112 | { |
||
113 | 20 | if (!$this->options['logging_enabled']) { |
|
114 | 20 | return false; |
|
115 | } |
||
116 | |||
117 | // Add the queue name and provider to the context |
||
118 | 1 | $context = array_merge(['queue' => $this->name, 'provider' => $this->getProvider()], $context); |
|
119 | |||
120 | 1 | return $this->logger->addRecord($level, $message, $context); |
|
121 | } |
||
122 | |||
123 | /** |
||
124 | * @param NotificationEvent $event |
||
125 | * @param string $eventName Name of the event |
||
126 | * @param EventDispatcherInterface $dispatcher |
||
127 | * @return bool |
||
128 | */ |
||
129 | 1 | public function onNotification(NotificationEvent $event, $eventName, EventDispatcherInterface $dispatcher) |
|
|
|||
130 | { |
||
131 | 1 | return false; |
|
132 | } |
||
133 | |||
134 | /** |
||
135 | * @param MessageEvent $event |
||
136 | * @return bool |
||
137 | */ |
||
138 | 1 | public function onMessageReceived(MessageEvent $event) |
|
142 | |||
143 | /** |
||
144 | * Merge override options while restricting what keys are allowed |
||
145 | * |
||
146 | * @param array $options An array of options that override the queue defaults |
||
147 | * |
||
148 | * @return array |
||
149 | */ |
||
150 | 7 | public function mergeOptions(array $options = []) |
|
151 | { |
||
152 | 7 | return array_merge($this->options, array_intersect_key($options, $this->options)); |
|
153 | } |
||
154 | |||
155 | abstract public function getProvider(); |
||
156 | |||
157 | abstract public function create(); |
||
158 | |||
159 | abstract public function publish(array $message, array $options = []); |
||
160 | |||
161 | abstract public function receive(array $options = []); |
||
162 | |||
163 | abstract public function delete($id); |
||
164 | |||
165 | abstract public function destroy(); |
||
166 | } |
||
167 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.