1 | <?php |
||
34 | class ResponseTagger |
||
35 | { |
||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | private $options; |
||
40 | |||
41 | /** |
||
42 | * @var TagHeaderFormatter |
||
43 | */ |
||
44 | private $headerFormatter; |
||
45 | |||
46 | /** |
||
47 | * @var array |
||
48 | */ |
||
49 | private $tags = []; |
||
50 | |||
51 | /** |
||
52 | * Create the response tagger with a tag header formatter and options. |
||
53 | * |
||
54 | * Supported options are: |
||
55 | * |
||
56 | * - header_formatter (TagHeaderFormatter) Default: CommaSeparatedTagHeaderFormatter with default header name |
||
57 | 7 | * - strict (bool) Default: false. If set to true, throws exception when adding empty tags |
|
58 | * |
||
59 | 7 | * @param array $options |
|
60 | 7 | */ |
|
61 | public function __construct(array $options = []) |
||
78 | |||
79 | /** |
||
80 | 3 | * Get the HTTP header name that will hold cache tags. |
|
81 | * |
||
82 | 3 | * @return string |
|
83 | */ |
||
84 | public function getTagsHeaderName() |
||
88 | |||
89 | /** |
||
90 | * Get the value for the HTTP tag header. |
||
91 | * |
||
92 | 4 | * This concatenates all tags and ensures correct encoding. |
|
93 | * |
||
94 | 4 | * @return string |
|
95 | */ |
||
96 | public function getTagsHeaderValue() |
||
100 | |||
101 | /** |
||
102 | 5 | * Check whether the tag handler has any tags to set on the response. |
|
103 | * |
||
104 | 5 | * @return bool True if this handler will set at least one tag |
|
105 | */ |
||
106 | public function hasTags() |
||
110 | |||
111 | /** |
||
112 | * Add tags to be set on the response. |
||
113 | * |
||
114 | * This must be called before any HTTP response is sent to the client. |
||
115 | * |
||
116 | * @param array $tags List of tags to add |
||
117 | * |
||
118 | 5 | * @throws InvalidTagException |
|
119 | * |
||
120 | 5 | * @return $this |
|
121 | */ |
||
122 | 5 | public function addTags(array $tags) |
|
134 | |||
135 | /** |
||
136 | * Remove all tags that have been recorded. |
||
137 | * |
||
138 | * This is usually called after adding the tags header to a response. It is |
||
139 | * automatically called by the tagResponse method. |
||
140 | 3 | */ |
|
141 | public function clear() |
||
145 | |||
146 | 2 | /** |
|
147 | 1 | * Set tags on a response and then clear the tags. |
|
148 | * |
||
149 | * @param ResponseInterface $response Original response |
||
150 | 1 | * @param bool $replace Whether to replace the current tags |
|
151 | * on the response |
||
152 | * |
||
153 | * @return ResponseInterface Tagged response |
||
154 | */ |
||
155 | public function tagResponse(ResponseInterface $response, $replace = false) |
||
170 | } |
||
171 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.