1 | <?php |
||
24 | class ResponseTagger |
||
25 | { |
||
26 | /** |
||
27 | * @var TagsInterface |
||
28 | */ |
||
29 | private $client; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $tags = []; |
||
35 | |||
36 | /** |
||
37 | * Constructor |
||
38 | * |
||
39 | * @param TagsInterface $client |
||
40 | */ |
||
41 | 2 | public function __construct(TagsInterface $client) |
|
45 | |||
46 | /** |
||
47 | * Get the HTTP header name that will hold cache tags. |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | 1 | public function getTagsHeaderName() |
|
55 | |||
56 | /** |
||
57 | * Get the value for the HTTP tag header. |
||
58 | * |
||
59 | * This concatenates all tags and ensures correct encoding. |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | 2 | public function getTagsHeaderValue() |
|
67 | |||
68 | /** |
||
69 | * Check whether the tag handler has any tags to set on the response. |
||
70 | * |
||
71 | * @return bool True if this handler will set at least one tag. |
||
72 | */ |
||
73 | 1 | public function hasTags() |
|
77 | |||
78 | /** |
||
79 | * Add tags to be set on the response. |
||
80 | * |
||
81 | * This must be called before any HTTP response is sent to the client. |
||
82 | * |
||
83 | * @param array $tags List of tags to add. |
||
84 | * |
||
85 | * @return $this |
||
86 | */ |
||
87 | 2 | public function addTags(array $tags) |
|
93 | |||
94 | /** |
||
95 | * Set tags on a response |
||
96 | * |
||
97 | * @param ResponseInterface $response Original response |
||
98 | * @param bool $replace Whether to replace the current tags |
||
99 | * on the response |
||
100 | * |
||
101 | * @return ResponseInterface Tagged response |
||
102 | */ |
||
103 | 1 | public function tagResponse(ResponseInterface $response, $replace = false) |
|
111 | } |
||
112 |