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 | * @var array |
||
42 | */ |
||
43 | protected $supportedServices = []; |
||
44 | |||
45 | /** |
||
46 | * MusicInfo constructor. |
||
47 | * |
||
48 | * @param $config |
||
49 | * |
||
50 | * @throws ServiceConfigurationException if musicinfo.service is missing |
||
51 | */ |
||
52 | 39 | public function __construct($config) |
|
73 | |||
74 | /** |
||
75 | * @param ClientInterface $client |
||
76 | * |
||
77 | * @return $this |
||
78 | */ |
||
79 | 39 | public function setClient(ClientInterface $client) |
|
85 | |||
86 | /** |
||
87 | * @return ClientInterface |
||
88 | */ |
||
89 | 39 | public function getClient() |
|
93 | |||
94 | /** |
||
95 | * Load service |
||
96 | * |
||
97 | * @param $service |
||
98 | * @param $init |
||
99 | * |
||
100 | * @return IMusicService |
||
101 | * |
||
102 | * @throws \Exception |
||
103 | */ |
||
104 | 39 | public function loadService($service, $init = false) |
|
122 | |||
123 | /** |
||
124 | * Merge shared config with service specific configuration |
||
125 | * |
||
126 | * @param $service |
||
127 | * |
||
128 | * @return array |
||
129 | */ |
||
130 | 39 | public function mergeConfig($service) |
|
144 | |||
145 | /** |
||
146 | * Load all services |
||
147 | * |
||
148 | * @param bool $initialize |
||
149 | * |
||
150 | * @return ArrayCollection |
||
151 | * @throws \Exception |
||
152 | */ |
||
153 | 5 | public function loadServices($initialize = false) |
|
161 | |||
162 | /** |
||
163 | * @param IMusicService $service |
||
164 | * @param $key |
||
165 | * |
||
166 | * @return $this |
||
167 | */ |
||
168 | 39 | public function addService(IMusicService $service, $key) |
|
174 | |||
175 | /** |
||
176 | * @return ArrayCollection |
||
177 | */ |
||
178 | 6 | public function getServices() |
|
182 | |||
183 | /** |
||
184 | * @param $key |
||
185 | * |
||
186 | * @return BaseService|null |
||
187 | */ |
||
188 | 24 | public function getService($key) |
|
197 | |||
198 | /** |
||
199 | * @param BaseService $service |
||
200 | * |
||
201 | * @return BaseService |
||
202 | * @throws ServiceConfigurationException |
||
203 | */ |
||
204 | 22 | public function initializeService(BaseService $service) |
|
212 | |||
213 | /** |
||
214 | * @param string $key |
||
215 | * |
||
216 | * @return $this |
||
217 | */ |
||
218 | 1 | public function removeService($key) |
|
226 | |||
227 | /** |
||
228 | * @return BaseService|null |
||
229 | */ |
||
230 | 1 | public function getPreferredService() |
|
234 | |||
235 | /** |
||
236 | * Perform Multi-service search |
||
237 | * |
||
238 | * @param $argument |
||
239 | * @param $type |
||
240 | * @param null $servicesArg |
||
241 | * |
||
242 | * @return ArrayCollection |
||
243 | * @throws \Exception |
||
244 | */ |
||
245 | 11 | public function doSearch($argument, $type, $servicesArg = null) |
|
262 | |||
263 | /** |
||
264 | * Return an arraycollection with (loaded) services |
||
265 | * |
||
266 | * @param mixed $servicesArg |
||
267 | * |
||
268 | * @return ArrayCollection |
||
269 | * @throws \Exception |
||
270 | */ |
||
271 | 11 | protected function _prepareSearch($servicesArg = null) |
|
292 | } |