1 | <?php |
||
25 | abstract class HttpProxyClient implements ProxyClientInterface |
||
26 | { |
||
27 | /** |
||
28 | * Dispatcher for invalidation HTTP requests. |
||
29 | * |
||
30 | * @var HttpDispatcher |
||
31 | */ |
||
32 | private $httpDispatcher; |
||
33 | |||
34 | /** |
||
35 | * @var RequestFactory |
||
36 | */ |
||
37 | private $requestFactory; |
||
38 | |||
39 | /** |
||
40 | * The options configured in the constructor argument or default values. |
||
41 | * |
||
42 | * @var array The resolved options |
||
43 | */ |
||
44 | protected $options; |
||
45 | |||
46 | /** |
||
47 | * Constructor. |
||
48 | * |
||
49 | * The base class has no options. |
||
50 | * |
||
51 | * @param HttpDispatcher $httpDispatcher Helper to send HTTP requests to caching proxy |
||
52 | * @param array $options Options for this client |
||
53 | * @param RequestFactory|null $messageFactory Factory for PSR-7 messages. If none supplied, |
||
54 | * a default one is created |
||
55 | */ |
||
56 | 35 | public function __construct( |
|
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | 22 | public function flush() |
|
73 | |||
74 | /** |
||
75 | * Get options resolver with default settings. |
||
76 | * |
||
77 | * @return OptionsResolver |
||
78 | */ |
||
79 | 35 | protected function configureOptions() |
|
80 | { |
||
81 | 35 | return new OptionsResolver(); |
|
82 | } |
||
83 | |||
84 | /** |
||
85 | * Create a request and queue it with the HTTP dispatcher. |
||
86 | * |
||
87 | * @param string $method |
||
88 | * @param string|UriInterface $url |
||
89 | * @param array $headers |
||
90 | */ |
||
91 | 30 | protected function queueRequest($method, $url, array $headers) |
|
97 | |||
98 | /** |
||
99 | * Make sure that the tags are valid. |
||
100 | * |
||
101 | * Reusable function for proxy clients. |
||
102 | * Escapes `,` and `\n` (newline) characters. |
||
103 | * |
||
104 | * @param array $tags The tags to escape |
||
105 | * |
||
106 | * @return array Sane tags |
||
107 | */ |
||
108 | protected function escapeTags(array $tags) |
||
116 | } |
||
117 |