1 | <?php |
||
28 | class ProviderRegistry |
||
29 | { |
||
30 | /** |
||
31 | * All services tagged with `uecode_qpush.receive` |
||
32 | * @var array |
||
33 | */ |
||
34 | private $queues; |
||
35 | |||
36 | /** |
||
37 | * Constructor. |
||
38 | */ |
||
39 | 1 | public function __construct() |
|
43 | |||
44 | /** |
||
45 | * Adds a Listener to the chain based on priority |
||
46 | * |
||
47 | * @param string $name The name of the Queue |
||
48 | * @param ProviderInterface $service The QueueProvider |
||
49 | */ |
||
50 | 1 | public function addProvider($name, ProviderInterface $service) |
|
51 | { |
||
52 | 1 | $this->queues[$name] = $service; |
|
53 | 1 | } |
|
54 | |||
55 | /** |
||
56 | * Returns the Queues |
||
57 | * |
||
58 | * @return array |
||
59 | */ |
||
60 | 1 | public function all() |
|
61 | { |
||
62 | 1 | return $this->queues; |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * Checks whether a Queue Provider exists in the Regisitry |
||
67 | * |
||
68 | * @param string $name The name of the Queue to check for |
||
69 | * |
||
70 | * @return Boolean |
||
71 | */ |
||
72 | 1 | public function has($name) |
|
73 | { |
||
74 | 1 | return array_key_exists($name, $this->queues); |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * Returns a Single QueueProvider by Queue Name |
||
79 | * |
||
80 | * @param string $name |
||
81 | * |
||
82 | * @throws \InvalidArgumentException |
||
83 | * |
||
84 | * @return ProviderInterface |
||
85 | */ |
||
86 | 1 | public function get($name) |
|
94 | } |
||
95 |