1 | <?php |
||
43 | class IndexService |
||
44 | { |
||
45 | /** |
||
46 | * @var TypoScriptConfiguration |
||
47 | */ |
||
48 | protected $configuration; |
||
49 | |||
50 | /** |
||
51 | * @var Site |
||
52 | */ |
||
53 | protected $site; |
||
54 | |||
55 | /** |
||
56 | * @var IndexQueueWorkerTask |
||
57 | */ |
||
58 | protected $contextTask; |
||
59 | |||
60 | /** |
||
61 | * @var Queue |
||
62 | */ |
||
63 | protected $indexQueue; |
||
64 | |||
65 | /** |
||
66 | * @var Dispatcher |
||
67 | */ |
||
68 | protected $signalSlotDispatcher; |
||
69 | |||
70 | /** |
||
71 | * IndexService constructor. |
||
72 | * @param Site $site |
||
73 | * @param Queue|null $queue |
||
74 | * @param Dispatcher|null $dispatcher |
||
75 | */ |
||
76 | 7 | public function __construct(Site $site, Queue $queue = null, Dispatcher $dispatcher = null) |
|
82 | |||
83 | /** |
||
84 | * @param \ApacheSolrForTypo3\Solr\Task\IndexQueueWorkerTask $contextTask |
||
85 | */ |
||
86 | 1 | public function setContextTask($contextTask) |
|
90 | |||
91 | /** |
||
92 | * @return \ApacheSolrForTypo3\Solr\Task\IndexQueueWorkerTask |
||
93 | */ |
||
94 | 6 | public function getContextTask() |
|
98 | |||
99 | /** |
||
100 | * Indexes items from the Index Queue. |
||
101 | * |
||
102 | * @param int $limit |
||
103 | * @return bool |
||
104 | */ |
||
105 | 6 | public function indexItems($limit) |
|
133 | |||
134 | /** |
||
135 | * Generates a message in the error log when an error occured. |
||
136 | * |
||
137 | * @param Item $itemToIndex |
||
138 | * @param \Exception $e |
||
139 | */ |
||
140 | protected function generateIndexingErrorLog(Item $itemToIndex, \Exception $e) |
||
146 | |||
147 | /** |
||
148 | * Builds an emits a singal for the IndexService. |
||
149 | * |
||
150 | * @param string $name |
||
151 | * @param array $arguments |
||
152 | * @return mixed |
||
153 | */ |
||
154 | 6 | protected function emitSignal($name, $arguments) |
|
158 | |||
159 | /** |
||
160 | * Indexes an item from the Index Queue. |
||
161 | * |
||
162 | * @param Item $item An index queue item to index |
||
163 | * @param TypoScriptConfiguration $configuration |
||
164 | * @return bool TRUE if the item was successfully indexed, FALSE otherwise |
||
165 | */ |
||
166 | 5 | protected function indexItem(Item $item, TypoScriptConfiguration $configuration) |
|
192 | |||
193 | /** |
||
194 | * A factory method to get an indexer depending on an item's configuration. |
||
195 | * |
||
196 | * By default all items are indexed using the default indexer |
||
197 | * (ApacheSolrForTypo3\Solr\IndexQueue\Indexer) coming with EXT:solr. Pages by default are |
||
198 | * configured to be indexed through a dedicated indexer |
||
199 | * (ApacheSolrForTypo3\Solr\IndexQueue\PageIndexer). In all other cases a dedicated indexer |
||
200 | * can be specified through TypoScript if needed. |
||
201 | * |
||
202 | * @param string $indexingConfigurationName Indexing configuration name. |
||
203 | * @param TypoScriptConfiguration $configuration |
||
204 | * @return Indexer |
||
205 | */ |
||
206 | 5 | protected function getIndexerByItem($indexingConfigurationName, TypoScriptConfiguration $configuration) |
|
221 | |||
222 | /** |
||
223 | * Gets the indexing progress. |
||
224 | * |
||
225 | * @return float Indexing progress as a two decimal precision float. f.e. 44.87 |
||
226 | */ |
||
227 | 2 | public function getProgress() |
|
242 | |||
243 | /** |
||
244 | * Initializes the $_SERVER['HTTP_HOST'] environment variable in CLI |
||
245 | * environments dependent on the Index Queue item's root page. |
||
246 | * |
||
247 | * When the Index Queue Worker task is executed by a cron job there is no |
||
248 | * HTTP_HOST since we are in a CLI environment. RealURL needs the host |
||
249 | * information to generate a proper URL though. Using the Index Queue item's |
||
250 | * root page information we can determine the correct host although being |
||
251 | * in a CLI environment. |
||
252 | * |
||
253 | * @param Item $item Index Queue item to use to determine the host. |
||
254 | * @param |
||
255 | */ |
||
256 | 5 | protected function initializeHttpServerEnvironment(Item $item) |
|
273 | } |
||
274 |