1 | <?php |
||
36 | class PageIndexerRequest |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * List of actions to perform during page rendering. |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $actions = []; |
||
45 | |||
46 | /** |
||
47 | * Parameters as sent from the Index Queue page indexer. |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $parameters = []; |
||
52 | |||
53 | /** |
||
54 | * Headers as sent from the Index Queue page indexer. |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $header = []; |
||
59 | |||
60 | /** |
||
61 | * Unique request ID. |
||
62 | * |
||
63 | * @var string |
||
64 | */ |
||
65 | protected $requestId; |
||
66 | |||
67 | /** |
||
68 | * Username to use for basic auth protected URLs. |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | protected $username = ''; |
||
73 | |||
74 | /** |
||
75 | * Password to use for basic auth protected URLs. |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | protected $password = ''; |
||
80 | |||
81 | /** |
||
82 | * An Index Queue item related to this request. |
||
83 | * |
||
84 | * @var Item |
||
85 | */ |
||
86 | protected $indexQueueItem = null; |
||
87 | |||
88 | /** |
||
89 | * Request timeout in seconds |
||
90 | * |
||
91 | * @var float |
||
92 | */ |
||
93 | protected $timeout; |
||
94 | |||
95 | /** |
||
96 | * @var \ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager |
||
97 | */ |
||
98 | protected $logger = null; |
||
99 | |||
100 | /** |
||
101 | * @var ExtensionConfiguration |
||
102 | */ |
||
103 | protected $extensionConfiguration; |
||
104 | |||
105 | /** |
||
106 | * PageIndexerRequest constructor. |
||
107 | * |
||
108 | * @param string $jsonEncodedParameters json encoded header |
||
109 | * @param SolrLogManager|null $solrLogManager |
||
110 | * @param ExtensionConfiguration|null $extensionConfiguration |
||
111 | */ |
||
112 | 20 | public function __construct($jsonEncodedParameters = null, SolrLogManager $solrLogManager = null, ExtensionConfiguration $extensionConfiguration = null) |
|
134 | |||
135 | /** |
||
136 | * Adds an action to perform during page rendering. |
||
137 | * |
||
138 | * @param string $action Action name. |
||
139 | */ |
||
140 | 8 | public function addAction($action) |
|
144 | |||
145 | /** |
||
146 | * Executes the request. |
||
147 | * |
||
148 | * Uses headers to submit additional data and avoiding to have these |
||
149 | * arguments integrated into the URL when created by RealURL. |
||
150 | * |
||
151 | * @param string $url The URL to request. |
||
152 | * @return PageIndexerResponse Response |
||
153 | */ |
||
154 | 5 | public function send($url) |
|
180 | |||
181 | /** |
||
182 | * This method is used to retrieve an url from the frontend and decode the response. |
||
183 | * |
||
184 | * @param string $url |
||
185 | * @param PageIndexerResponse $response |
||
186 | * @return mixed |
||
187 | */ |
||
188 | 5 | protected function getUrlAndDecodeResponse($url, PageIndexerResponse $response) |
|
212 | |||
213 | /** |
||
214 | * Generates the headers to be send with the request. |
||
215 | * |
||
216 | * @return string[] Array of HTTP headers. |
||
217 | */ |
||
218 | 6 | public function getHeaders() |
|
246 | |||
247 | /** |
||
248 | * Adds an HTTP header to be send with the request. |
||
249 | * |
||
250 | * @param string $header HTTP header |
||
251 | */ |
||
252 | public function addHeader($header) |
||
256 | |||
257 | /** |
||
258 | * Checks whether this is a legitimate request coming from the Index Queue |
||
259 | * page indexer worker task. |
||
260 | * |
||
261 | * @return bool TRUE if it's a legitimate request, FALSE otherwise. |
||
262 | */ |
||
263 | 2 | public function isAuthenticated() |
|
283 | |||
284 | /** |
||
285 | * Gets the list of actions to perform during page rendering. |
||
286 | * |
||
287 | * @return array List of actions |
||
288 | */ |
||
289 | public function getActions() |
||
293 | |||
294 | /** |
||
295 | * Gets the request's parameters. |
||
296 | * |
||
297 | * @return array Request parameters. |
||
298 | */ |
||
299 | public function getParameters() |
||
303 | |||
304 | /** |
||
305 | * Gets the request's unique ID. |
||
306 | * |
||
307 | * @return string Unique request ID. |
||
308 | */ |
||
309 | 3 | public function getRequestId() |
|
313 | |||
314 | /** |
||
315 | * Gets a specific parameter's value. |
||
316 | * |
||
317 | * @param string $parameterName The parameter to retrieve. |
||
318 | * @return mixed NULL if a parameter was not set or it's value otherwise. |
||
319 | */ |
||
320 | 10 | public function getParameter($parameterName) |
|
324 | |||
325 | /** |
||
326 | * Sets a request's parameter and its value. |
||
327 | * |
||
328 | * @param string $parameter Parameter name |
||
329 | * @param string $value Parameter value. |
||
330 | */ |
||
331 | 11 | public function setParameter($parameter, $value) |
|
339 | |||
340 | /** |
||
341 | * Sets username and password to be used for a basic auth request header. |
||
342 | * |
||
343 | * @param string $username username. |
||
344 | * @param string $password password. |
||
345 | */ |
||
346 | 1 | public function setAuthorizationCredentials($username, $password) |
|
351 | |||
352 | /** |
||
353 | * Sets the Index Queue item this request is related to. |
||
354 | * |
||
355 | * @param Item $item Related Index Queue item. |
||
356 | */ |
||
357 | 6 | public function setIndexQueueItem(Item $item) |
|
361 | |||
362 | /** |
||
363 | * Returns the request timeout in seconds |
||
364 | * |
||
365 | * @return float |
||
366 | */ |
||
367 | 1 | public function getTimeout() |
|
371 | |||
372 | /** |
||
373 | * Sets the request timeout in seconds |
||
374 | * |
||
375 | * @param float $timeout Timeout seconds |
||
376 | */ |
||
377 | public function setTimeout($timeout) |
||
381 | |||
382 | /** |
||
383 | * Fetches a page by sending the configured headers. |
||
384 | * |
||
385 | * @param string $url |
||
386 | * @param string[] $headers |
||
387 | * @param float $timeout |
||
388 | * @return string |
||
389 | */ |
||
390 | 1 | protected function getUrl($url, $headers, $timeout) |
|
410 | } |
||
411 |