1 | <?php |
||
25 | class MultiplexerClient implements BanInterface, PurgeInterface, RefreshInterface |
||
26 | { |
||
27 | /** |
||
28 | * @var ProxyClientInterface[] |
||
29 | */ |
||
30 | private $proxyClients; |
||
31 | |||
32 | /** |
||
33 | * MultiplexerClient constructor. |
||
34 | * |
||
35 | * @param ProxyClientInterface[] $proxyClients The list of Proxy clients |
||
36 | */ |
||
37 | 7 | public function __construct(array $proxyClients) |
|
49 | |||
50 | /** |
||
51 | * Forwards to all clients. |
||
52 | * |
||
53 | * @param array $headers HTTP headers that path must match to be banned |
||
54 | * |
||
55 | * @return $this |
||
56 | */ |
||
57 | 1 | public function ban(array $headers) |
|
63 | |||
64 | /** |
||
65 | * Forwards to all clients. |
||
66 | * |
||
67 | * @param string $path Regular expression pattern for URI to invalidate |
||
68 | * @param string $contentType Regular expression pattern for the content type to limit banning, for instance |
||
69 | * 'text' |
||
70 | * @param array|string $hosts Regular expression of a host name or list of exact host names to limit banning |
||
71 | * |
||
72 | * @return $this |
||
73 | */ |
||
74 | 1 | public function banPath($path, $contentType = null, $hosts = null) |
|
80 | |||
81 | /** |
||
82 | * Forwards to all clients. |
||
83 | * |
||
84 | * @throws ExceptionCollection If any errors occurred during flush |
||
85 | * |
||
86 | * @return int The number of cache invalidations performed per caching server |
||
87 | */ |
||
88 | 1 | public function flush() |
|
97 | |||
98 | /** |
||
99 | * Forwards to all clients. |
||
100 | * |
||
101 | * @param string $url Path or URL to purge |
||
102 | * @param array $headers Extra HTTP headers to send to the caching proxy (optional) |
||
103 | * |
||
104 | * @return $this |
||
105 | */ |
||
106 | 1 | public function purge($url, array $headers = array()) |
|
107 | { |
||
108 | 1 | $this->invoke(PurgeInterface::class, 'purge', [$url, $headers]); |
|
109 | |||
110 | 1 | return $this; |
|
111 | } |
||
112 | |||
113 | /** |
||
114 | * Forwards to all clients. |
||
115 | * |
||
116 | * @param string $url Path or URL to refresh |
||
117 | * @param array $headers Extra HTTP headers to send to the caching proxy (optional) |
||
118 | * |
||
119 | * @return $this |
||
120 | */ |
||
121 | 1 | public function refresh($url, array $headers = []) |
|
127 | |||
128 | /** |
||
129 | * Helper function to invoke the given $method on all available ProxyClients implementing the given $interface. |
||
130 | * |
||
131 | * @param string $interface The FQN of the interface |
||
132 | * @param string $method The method to invoke |
||
133 | * @param array $arguments The arguments to be passed to the method |
||
134 | */ |
||
135 | 4 | private function invoke($interface, $method, array $arguments) |
|
143 | } |
||
144 |