1 | <?php |
||
21 | class MusicInfo |
||
22 | { |
||
23 | use PropertyTrait; |
||
24 | /** |
||
25 | * @var ClientInterface |
||
26 | */ |
||
27 | protected $client; |
||
28 | |||
29 | /** |
||
30 | * @var ArrayCollection |
||
31 | */ |
||
32 | protected $services; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $config; |
||
38 | |||
39 | /** |
||
40 | * Supported Services |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $supportedServices = []; |
||
45 | |||
46 | /** |
||
47 | * MusicInfo constructor. |
||
48 | * |
||
49 | * @param $config |
||
50 | * |
||
51 | * @throws ServiceConfigurationException if musicinfo.service is missing |
||
52 | */ |
||
53 | 43 | public function __construct($config) |
|
74 | |||
75 | /** |
||
76 | * @param ClientInterface $client |
||
77 | * |
||
78 | * @return $this |
||
79 | */ |
||
80 | 43 | public function setClient(ClientInterface $client) |
|
86 | |||
87 | /** |
||
88 | * @return ClientInterface |
||
89 | */ |
||
90 | 43 | public function getClient() |
|
94 | |||
95 | /** |
||
96 | * Load service |
||
97 | * |
||
98 | * @param $service |
||
99 | * @param $init |
||
100 | * |
||
101 | * @return IMusicService |
||
102 | * |
||
103 | * @throws \Exception |
||
104 | */ |
||
105 | 43 | public function loadService($service, $init = false) |
|
127 | |||
128 | /** |
||
129 | * Merge shared config with service specific configuration |
||
130 | * |
||
131 | * @param $service |
||
132 | * |
||
133 | * @return array |
||
134 | */ |
||
135 | 43 | public function mergeConfig($service) |
|
149 | |||
150 | /** |
||
151 | * Load all services |
||
152 | * |
||
153 | * @param bool $initialize |
||
154 | * |
||
155 | * @return ArrayCollection |
||
156 | * @throws \Exception |
||
157 | */ |
||
158 | 5 | public function loadServices($initialize = false) |
|
166 | |||
167 | /** |
||
168 | * @param IMusicService $service |
||
169 | * @param $key |
||
170 | * |
||
171 | * @return $this |
||
172 | */ |
||
173 | 43 | public function addService(IMusicService $service, $key) |
|
179 | |||
180 | /** |
||
181 | * @return ArrayCollection |
||
182 | */ |
||
183 | 8 | public function getServices() |
|
187 | |||
188 | /** |
||
189 | * @param $key |
||
190 | * |
||
191 | * @return BaseService|null |
||
192 | */ |
||
193 | 26 | public function getService($key) |
|
202 | |||
203 | /** |
||
204 | * @param BaseService $service |
||
205 | * |
||
206 | * @return BaseService |
||
207 | * @throws ServiceConfigurationException |
||
208 | */ |
||
209 | 24 | public function initializeService(BaseService $service) |
|
217 | |||
218 | /** |
||
219 | * @param string $key |
||
220 | * |
||
221 | * @return $this |
||
222 | */ |
||
223 | 1 | public function removeService($key) |
|
231 | |||
232 | /** |
||
233 | * @return BaseService|null |
||
234 | */ |
||
235 | 1 | public function getPreferredService() |
|
239 | |||
240 | /** |
||
241 | * Perform Multi-service search |
||
242 | * |
||
243 | * @param $argument |
||
244 | * @param $type |
||
245 | * @param null $servicesArg |
||
246 | * |
||
247 | * @return ArrayCollection |
||
248 | * @throws \Exception |
||
249 | */ |
||
250 | 15 | public function doSearch($argument, $type, $servicesArg = null) |
|
267 | |||
268 | /** |
||
269 | * Return an arraycollection with (loaded) services |
||
270 | * |
||
271 | * @param mixed $servicesArg |
||
272 | * |
||
273 | * @return ArrayCollection |
||
274 | * @throws \Exception |
||
275 | */ |
||
276 | 15 | protected function _prepareSearch($servicesArg = null) |
|
297 | } |
||
298 |