1 | <?php |
||
23 | class MusicInfo |
||
24 | { |
||
25 | use PropertyTrait; |
||
26 | /** |
||
27 | * @var ClientInterface |
||
28 | */ |
||
29 | protected $client; |
||
30 | |||
31 | /** |
||
32 | * @var ArrayCollection |
||
33 | */ |
||
34 | protected $services; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $config; |
||
40 | |||
41 | /** |
||
42 | * @var CacheItemPoolInterface |
||
43 | */ |
||
44 | protected $cache; |
||
45 | |||
46 | /** |
||
47 | * Supported Services |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $supportedServices = []; |
||
52 | |||
53 | /** |
||
54 | * MusicInfo constructor. |
||
55 | * |
||
56 | * @param $config |
||
57 | * |
||
58 | * @throws ServiceConfigurationException if musicinfo.service is missing |
||
59 | */ |
||
60 | 39 | public function __construct($config) |
|
85 | |||
86 | /** |
||
87 | * @param ClientInterface $client |
||
88 | * |
||
89 | * @return $this |
||
90 | */ |
||
91 | 39 | public function setClient(ClientInterface $client) |
|
97 | |||
98 | /** |
||
99 | * @return ClientInterface |
||
100 | */ |
||
101 | 39 | public function getClient() |
|
105 | |||
106 | /** |
||
107 | * @param CacheItemPoolInterface $cacheItemPool |
||
108 | * @return $this |
||
109 | */ |
||
110 | 39 | public function setCache(CacheItemPoolInterface $cacheItemPool) |
|
116 | |||
117 | /** |
||
118 | * @return CacheItemPoolInterface |
||
119 | */ |
||
120 | 39 | public function getCache() |
|
124 | |||
125 | /** |
||
126 | * Load service |
||
127 | * |
||
128 | * @param $service |
||
129 | * @param $init |
||
130 | * |
||
131 | * @return IMusicService |
||
132 | * |
||
133 | * @throws \Exception |
||
134 | */ |
||
135 | 39 | public function loadService($service, $init = false) |
|
158 | |||
159 | /** |
||
160 | * Merge shared config with service specific configuration |
||
161 | * |
||
162 | * @param $service |
||
163 | * |
||
164 | * @return array |
||
165 | */ |
||
166 | 39 | public function mergeConfig($service) |
|
180 | |||
181 | /** |
||
182 | * Load all services |
||
183 | * |
||
184 | * @param bool $initialize |
||
185 | * |
||
186 | * @return ArrayCollection |
||
187 | * @throws \Exception |
||
188 | */ |
||
189 | 5 | public function loadServices($initialize = false) |
|
197 | |||
198 | /** |
||
199 | * @param IMusicService $service |
||
200 | * @param $key |
||
201 | * |
||
202 | * @return $this |
||
203 | */ |
||
204 | 39 | public function addService(IMusicService $service, $key) |
|
210 | |||
211 | /** |
||
212 | * @return ArrayCollection |
||
213 | */ |
||
214 | 6 | public function getServices() |
|
218 | |||
219 | /** |
||
220 | * @param $key |
||
221 | * |
||
222 | * @return BaseService|null |
||
223 | */ |
||
224 | 24 | public function getService($key) |
|
233 | |||
234 | /** |
||
235 | * @param BaseService $service |
||
236 | * |
||
237 | * @return BaseService |
||
238 | * @throws ServiceConfigurationException |
||
239 | */ |
||
240 | 22 | public function initializeService(BaseService $service) |
|
248 | |||
249 | /** |
||
250 | * @param string $key |
||
251 | * |
||
252 | * @return $this |
||
253 | */ |
||
254 | 1 | public function removeService($key) |
|
262 | |||
263 | /** |
||
264 | * @return BaseService|null |
||
265 | */ |
||
266 | 1 | public function getPreferredService() |
|
270 | |||
271 | /** |
||
272 | * Perform Multi-service search |
||
273 | * |
||
274 | * @param $argument |
||
275 | * @param $type |
||
276 | * @param null $servicesArg |
||
277 | * |
||
278 | * @return ArrayCollection |
||
279 | * @throws \Exception |
||
280 | */ |
||
281 | 11 | public function doSearch($argument, $type, $servicesArg = null) |
|
298 | |||
299 | /** |
||
300 | * Return an arraycollection with (loaded) services |
||
301 | * |
||
302 | * @param mixed $servicesArg |
||
303 | * |
||
304 | * @return ArrayCollection |
||
305 | * @throws \Exception |
||
306 | */ |
||
307 | 11 | protected function _prepareSearch($servicesArg = null) |
|
328 | } |
||
329 |