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 | */ |
||
110 | 17 | public function __construct($jsonEncodedParameters = null) |
|
131 | |||
132 | /** |
||
133 | * Adds an action to perform during page rendering. |
||
134 | * |
||
135 | * @param string $action Action name. |
||
136 | */ |
||
137 | 8 | public function addAction($action) |
|
141 | |||
142 | /** |
||
143 | * Executes the request. |
||
144 | * |
||
145 | * Uses headers to submit additional data and avoiding to have these |
||
146 | * arguments integrated into the URL when created by RealURL. |
||
147 | * |
||
148 | * @param string $url The URL to request. |
||
149 | * @return PageIndexerResponse Response |
||
150 | */ |
||
151 | 5 | public function send($url) |
|
177 | |||
178 | /** |
||
179 | * This method is used to retrieve an url from the frontend and decode the response. |
||
180 | * |
||
181 | * @param string $url |
||
182 | * @param PageIndexerResponse $response |
||
183 | * @return mixed |
||
184 | */ |
||
185 | 5 | protected function getUrlAndDecodeResponse($url, PageIndexerResponse $response) |
|
209 | |||
210 | /** |
||
211 | * Generates the headers to be send with the request. |
||
212 | * |
||
213 | * @return string[] Array of HTTP headers. |
||
214 | */ |
||
215 | 6 | public function getHeaders() |
|
243 | |||
244 | /** |
||
245 | * Adds an HTTP header to be send with the request. |
||
246 | * |
||
247 | * @param string $header HTTP header |
||
248 | */ |
||
249 | public function addHeader($header) |
||
253 | |||
254 | /** |
||
255 | * Checks whether this is a legitimate request coming from the Index Queue |
||
256 | * page indexer worker task. |
||
257 | * |
||
258 | * @return bool TRUE if it's a legitimate request, FALSE otherwise. |
||
259 | */ |
||
260 | 2 | public function isAuthenticated() |
|
280 | |||
281 | /** |
||
282 | * Gets the list of actions to perform during page rendering. |
||
283 | * |
||
284 | * @return array List of actions |
||
285 | */ |
||
286 | public function getActions() |
||
290 | |||
291 | /** |
||
292 | * Gets the request's parameters. |
||
293 | * |
||
294 | * @return array Request parameters. |
||
295 | */ |
||
296 | public function getParameters() |
||
300 | |||
301 | /** |
||
302 | * Gets the request's unique ID. |
||
303 | * |
||
304 | * @return string Unique request ID. |
||
305 | */ |
||
306 | 1 | public function getRequestId() |
|
310 | |||
311 | /** |
||
312 | * Gets a specific parameter's value. |
||
313 | * |
||
314 | * @param string $parameterName The parameter to retrieve. |
||
315 | * @return mixed NULL if a parameter was not set or it's value otherwise. |
||
316 | */ |
||
317 | 7 | public function getParameter($parameterName) |
|
321 | |||
322 | /** |
||
323 | * Sets a request's parameter and its value. |
||
324 | * |
||
325 | * @param string $parameter Parameter name |
||
326 | * @param mixed $value Parameter value. |
||
327 | */ |
||
328 | 8 | public function setParameter($parameter, $value) |
|
336 | |||
337 | /** |
||
338 | * Sets username and password to be used for a basic auth request header. |
||
339 | * |
||
340 | * @param string $username username. |
||
341 | * @param string $password password. |
||
342 | */ |
||
343 | 1 | public function setAuthorizationCredentials($username, $password) |
|
348 | |||
349 | /** |
||
350 | * Sets the Index Queue item this request is related to. |
||
351 | * |
||
352 | * @param Item $item Related Index Queue item. |
||
353 | */ |
||
354 | 6 | public function setIndexQueueItem(Item $item) |
|
358 | |||
359 | /** |
||
360 | * Returns the request timeout in seconds |
||
361 | * |
||
362 | * @return float |
||
363 | */ |
||
364 | 1 | public function getTimeout() |
|
368 | |||
369 | /** |
||
370 | * Sets the request timeout in seconds |
||
371 | * |
||
372 | * @param float $timeout Timeout seconds |
||
373 | */ |
||
374 | public function setTimeout($timeout) |
||
378 | |||
379 | /** |
||
380 | * Fetches a page by sending the configured headers. |
||
381 | * |
||
382 | * @param string $url |
||
383 | * @param string[] $headers |
||
384 | * @param float $timeout |
||
385 | * @return string |
||
386 | */ |
||
387 | 1 | protected function getUrl($url, $headers, $timeout) |
|
407 | } |
||
408 |