1 | <?php |
||
27 | class MultiplexerClient implements BanCapable, PurgeCapable, RefreshCapable, TagCapable |
||
28 | { |
||
29 | /** |
||
30 | * @var ProxyClient[] |
||
31 | */ |
||
32 | private $proxyClients; |
||
33 | |||
34 | /** |
||
35 | * MultiplexerClient constructor. |
||
36 | * |
||
37 | * @param ProxyClient[] $proxyClients The list of Proxy clients |
||
38 | */ |
||
39 | 8 | public function __construct(array $proxyClients) |
|
52 | |||
53 | /** |
||
54 | * Forwards to all clients. |
||
55 | * |
||
56 | * @param array $headers HTTP headers that path must match to be banned |
||
57 | * |
||
58 | * @return $this |
||
59 | */ |
||
60 | 1 | public function ban(array $headers) |
|
66 | |||
67 | /** |
||
68 | * Forwards to all clients. |
||
69 | * |
||
70 | * @param string $path Regular expression pattern for URI to invalidate |
||
71 | * @param string $contentType Regular expression pattern for the content type to limit banning, for instance |
||
72 | * 'text' |
||
73 | * @param array|string $hosts Regular expression of a host name or list of exact host names to limit banning |
||
74 | * |
||
75 | * @return $this |
||
76 | */ |
||
77 | 1 | public function banPath($path, $contentType = null, $hosts = null) |
|
83 | |||
84 | /** |
||
85 | * Forwards to all clients. |
||
86 | * |
||
87 | * @throws ExceptionCollection If any errors occurred during flush |
||
88 | * |
||
89 | * @return int The number of cache invalidations performed per caching server |
||
90 | */ |
||
91 | 1 | public function flush() |
|
100 | |||
101 | /** |
||
102 | * Forwards tag invalidation request to all clients. |
||
103 | * |
||
104 | * {@inheritdoc} |
||
105 | * |
||
106 | * @param array $tags |
||
107 | * |
||
108 | * @return $this |
||
109 | */ |
||
110 | 1 | public function invalidateTags(array $tags) |
|
116 | |||
117 | /** |
||
118 | * Forwards to all clients. |
||
119 | * |
||
120 | * @param string $url Path or URL to purge |
||
121 | * @param array $headers Extra HTTP headers to send to the caching proxy (optional) |
||
122 | * |
||
123 | * @return $this |
||
124 | */ |
||
125 | 1 | public function purge($url, array $headers = []) |
|
131 | |||
132 | /** |
||
133 | * Forwards to all clients. |
||
134 | * |
||
135 | * @param string $url Path or URL to refresh |
||
136 | * @param array $headers Extra HTTP headers to send to the caching proxy (optional) |
||
137 | * |
||
138 | * @return $this |
||
139 | */ |
||
140 | 1 | public function refresh($url, array $headers = []) |
|
146 | |||
147 | /** |
||
148 | * Invoke the given $method on all available ProxyClients implementing the |
||
149 | * given $interface. |
||
150 | * |
||
151 | * @param string $interface The FQN of the interface |
||
152 | * @param string $method The method to invoke |
||
153 | * @param array $arguments The arguments to be passed to the method |
||
154 | */ |
||
155 | 5 | private function invoke($interface, $method, array $arguments) |
|
161 | |||
162 | /** |
||
163 | * Invoke the given $method on the first available ProxyClient implementing |
||
164 | * the given $interface. |
||
165 | * |
||
166 | * @param string $interface The FQN of the interface |
||
167 | * @param string $method The method to invoke |
||
168 | * @param array $arguments The arguments to be passed to the method |
||
169 | * |
||
170 | * @return mixed Return value of ProxyClient method call |
||
171 | * |
||
172 | * @throws UnsupportedProxyOperationException |
||
173 | */ |
||
174 | private function invokeFirst($interface, $method, array $arguments) |
||
182 | |||
183 | /** |
||
184 | * Get proxy clients that implement a feature interface. |
||
185 | * |
||
186 | * @param string $interface |
||
187 | * |
||
188 | * @return ProxyClient[] |
||
189 | */ |
||
190 | 5 | private function getProxyClients($interface) |
|
199 | } |
||
200 |