1 | <?php |
||
12 | class MusicInfo |
||
13 | { |
||
14 | use PropertyTrait; |
||
15 | /** |
||
16 | * @var ClientInterface |
||
17 | */ |
||
18 | protected $client; |
||
19 | |||
20 | /** |
||
21 | * @var ArrayCollection |
||
22 | */ |
||
23 | protected $services; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $config; |
||
29 | |||
30 | /** |
||
31 | * Supported Services |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $supportedServices = []; |
||
35 | |||
36 | /** |
||
37 | * MusicInfo constructor. |
||
38 | * |
||
39 | * @param $config |
||
40 | * |
||
41 | * @throws ServiceConfigurationException if musicinfo.service is missing |
||
42 | */ |
||
43 | 27 | public function __construct($config) |
|
64 | |||
65 | /** |
||
66 | * @param ClientInterface $client |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | 27 | public function setClient(ClientInterface $client) |
|
76 | |||
77 | /** |
||
78 | * @return ClientInterface |
||
79 | */ |
||
80 | 27 | public function getClient() |
|
84 | |||
85 | /** |
||
86 | * Load service |
||
87 | * |
||
88 | * @param $service |
||
89 | * @param $init |
||
90 | * |
||
91 | * @return IMusicService |
||
92 | * |
||
93 | * @throws \Exception |
||
94 | */ |
||
95 | 27 | public function loadService($service, $init = false) |
|
113 | |||
114 | /** |
||
115 | * Merge shared config with service specific configuration |
||
116 | * |
||
117 | * @param $service |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | 27 | public function mergeConfig($service) |
|
135 | |||
136 | /** |
||
137 | * Load all services |
||
138 | * |
||
139 | * @param bool $initialize |
||
140 | * |
||
141 | * @return ArrayCollection |
||
142 | * @throws \Exception |
||
143 | */ |
||
144 | 4 | public function loadServices($initialize = false) |
|
152 | |||
153 | /** |
||
154 | * @param IMusicService $service |
||
155 | * @param $key |
||
156 | * |
||
157 | * @return $this |
||
158 | */ |
||
159 | 27 | public function addService(IMusicService $service, $key) |
|
165 | |||
166 | /** |
||
167 | * @return ArrayCollection |
||
168 | */ |
||
169 | 4 | public function getServices() |
|
173 | |||
174 | /** |
||
175 | * @param $key |
||
176 | * |
||
177 | * @return BaseService|null |
||
178 | */ |
||
179 | 13 | public function getService($key) |
|
188 | |||
189 | /** |
||
190 | * @param BaseService $service |
||
191 | * |
||
192 | * @return BaseService |
||
193 | * @throws ServiceConfigurationException |
||
194 | */ |
||
195 | 11 | public function initializeService(BaseService $service) |
|
203 | |||
204 | /** |
||
205 | * @param string $key |
||
206 | * |
||
207 | * @return $this |
||
208 | */ |
||
209 | 1 | public function removeService($key) |
|
217 | |||
218 | /** |
||
219 | * @return BaseService|null |
||
220 | */ |
||
221 | 1 | public function getPreferredService() |
|
225 | |||
226 | /** |
||
227 | * Perform Multi-service search |
||
228 | * |
||
229 | * @param $argument |
||
230 | * @param $type |
||
231 | * @param null $servicesArg |
||
232 | * |
||
233 | * @return ArrayCollection |
||
234 | * @throws \Exception |
||
235 | */ |
||
236 | 7 | public function doSearch($argument, $type, $servicesArg = null) |
|
252 | |||
253 | /** |
||
254 | * Return an arraycollection with (loaded) services |
||
255 | * |
||
256 | * @param mixed $servicesArg |
||
257 | * |
||
258 | * @return ArrayCollection |
||
259 | * @throws \Exception |
||
260 | */ |
||
261 | 7 | protected function _prepareSearch($servicesArg = null) |
|
282 | } |