1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\IndexQueue; |
4
|
|
|
|
5
|
|
|
/*************************************************************** |
6
|
|
|
* Copyright notice |
7
|
|
|
* |
8
|
|
|
* (c) 2010-2015 Ingo Renner <[email protected]> |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
|
28
|
|
|
use ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper\Dispatcher; |
29
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
30
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Checks for Index Queue page indexer requests and handles the actions |
34
|
|
|
* requested by them. |
35
|
|
|
* |
36
|
|
|
* @author Ingo Renner <[email protected]> |
37
|
|
|
*/ |
38
|
|
|
class PageIndexerRequestHandler implements SingletonInterface |
39
|
|
|
{ |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Index Queue page indexer request. |
43
|
|
|
* |
44
|
|
|
* @var PageIndexerRequest |
45
|
|
|
*/ |
46
|
|
|
protected $request; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Index Queue page indexer response. |
50
|
|
|
* |
51
|
|
|
* @var PageIndexerResponse |
52
|
|
|
*/ |
53
|
|
|
protected $response; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Index Queue page indexer frontend helper dispatcher. |
57
|
|
|
* |
58
|
|
|
* @var Dispatcher |
59
|
|
|
*/ |
60
|
|
|
protected $dispatcher; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Constructor. |
64
|
|
|
* |
65
|
|
|
* Initializes request, response, and dispatcher. |
66
|
|
|
* @param string|null $jsonEncodedParameters |
67
|
2 |
|
*/ |
68
|
|
|
public function __construct(string $jsonEncodedParameters = null) |
69
|
2 |
|
{ |
70
|
2 |
|
$this->dispatcher = GeneralUtility::makeInstance(Dispatcher::class); |
71
|
2 |
|
$this->request = GeneralUtility::makeInstance(PageIndexerRequest::class, /** @scrutinizer ignore-type */ $jsonEncodedParameters); |
72
|
2 |
|
$this->response = GeneralUtility::makeInstance(PageIndexerResponse::class); |
73
|
2 |
|
$this->response->setRequestId($this->request->getRequestId()); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Authenticates the request, runs the frontend helpers defined by the |
78
|
|
|
* request, and registers its own shutdown() method for execution at |
79
|
|
|
* hook_eofe in tslib/class.tslib_fe.php. |
80
|
|
|
*/ |
81
|
|
|
public function run() |
82
|
|
|
{ |
83
|
|
|
$this->dispatcher->dispatch($this->request, $this->response); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Completes the Index Queue page indexer request and returns the response |
88
|
|
|
* with the collected results. |
89
|
|
|
*/ |
90
|
|
|
public function shutdown() |
91
|
|
|
{ |
92
|
|
|
$this->dispatcher->shutdown(); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Gets the Index Queue page indexer request. |
97
|
|
|
* |
98
|
|
|
* @return PageIndexerRequest |
99
|
|
|
*/ |
100
|
|
|
public function getRequest() |
101
|
|
|
{ |
102
|
|
|
return $this->request; |
103
|
|
|
} |
104
|
2 |
|
|
105
|
|
|
/** |
106
|
2 |
|
* Gets the Index Queue page indexer response. |
107
|
|
|
* |
108
|
|
|
* @return PageIndexerResponse |
109
|
|
|
*/ |
110
|
|
|
public function getResponse() |
111
|
|
|
{ |
112
|
|
|
return $this->response; |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|