1 | <?php |
||
19 | class PagerProviderRegistry |
||
20 | { |
||
21 | /** @var ServiceLocator */ |
||
22 | private $providers; |
||
23 | |||
24 | 7 | public function __construct(ServiceLocator $providers) |
|
28 | |||
29 | /** |
||
30 | * Gets all registered providers. |
||
31 | * |
||
32 | * Providers will be indexed by "index" strings in the returned array. |
||
33 | * |
||
34 | * @return PagerProviderInterface[] |
||
35 | */ |
||
36 | 1 | public function getProviders() |
|
37 | { |
||
38 | 1 | return \array_reduce(\array_keys($this->providers->getProvidedServices()), function ($carry, $index) { |
|
39 | 1 | return $carry + [$index => $this->providers->get($index)]; |
|
40 | 1 | }, []); |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * Gets the provider for an index. |
||
45 | * |
||
46 | * @throws \InvalidArgumentException if no provider was registered for the index and type |
||
47 | */ |
||
48 | 2 | public function getProvider(string $index): PagerProviderInterface |
|
56 | } |
||
57 |