2121use ApacheSolrForTypo3 \Solr \Event \Indexing \AfterPageDocumentIsCreatedForIndexingEvent ;
2222use ApacheSolrForTypo3 \Solr \Event \Indexing \BeforeDocumentsAreIndexedEvent ;
2323use ApacheSolrForTypo3 \Solr \Event \Indexing \BeforePageDocumentIsProcessedForIndexingEvent ;
24- use ApacheSolrForTypo3 \Solr \Exception ;
24+ use ApacheSolrForTypo3 \Solr \Exception as SolrException ;
2525use ApacheSolrForTypo3 \Solr \FieldProcessor \Service ;
2626use ApacheSolrForTypo3 \Solr \IndexQueue \Item ;
2727use ApacheSolrForTypo3 \Solr \IndexQueue \PageIndexerRequest ;
2828use ApacheSolrForTypo3 \Solr \IndexQueue \PageIndexerResponse ;
2929use ApacheSolrForTypo3 \Solr \IndexQueue \Queue ;
30+ use ApacheSolrForTypo3 \Solr \NoSolrConnectionFoundException ;
3031use ApacheSolrForTypo3 \Solr \System \Configuration \TypoScriptConfiguration ;
3132use ApacheSolrForTypo3 \Solr \System \Logging \DebugWriter ;
3233use ApacheSolrForTypo3 \Solr \System \Logging \SolrLogManager ;
3334use ApacheSolrForTypo3 \Solr \System \Solr \Document \Document ;
3435use ApacheSolrForTypo3 \Solr \System \Solr \SolrConnection ;
3536use ApacheSolrForTypo3 \Solr \Util ;
37+ use Doctrine \DBAL \Exception as DBALException ;
3638use Psr \EventDispatcher \EventDispatcherInterface ;
3739use Psr \Http \Message \ServerRequestInterface ;
3840use Psr \Log \LogLevel ;
@@ -200,9 +202,16 @@ public function __invoke(AfterCacheableContentIsGeneratedEvent $event): void
200202
201203 /**
202204 * Index item
205+ *
206+ * @throws DBALException
207+ * @throws SolrException
208+ * @throws Throwable
203209 */
204- protected function index (Item $ indexQueueItem , ServerRequestInterface $ request , TypoScriptFrontendController $ tsfe ): void
205- {
210+ protected function index (
211+ Item $ indexQueueItem ,
212+ ServerRequestInterface $ request ,
213+ TypoScriptFrontendController $ tsfe ,
214+ ): void {
206215 /** @var PageArguments $pageArguments */
207216 $ pageArguments = $ request ->getAttribute ('routing ' );
208217 $ pageInformation = $ request ->getAttribute ('frontend.page.information ' );
@@ -218,7 +227,12 @@ protected function index(Item $indexQueueItem, ServerRequestInterface $request,
218227 $ this ->getAccessRootline (),
219228 $ pageInformation ->getMountPoint ()
220229 );
221- $ document = $ this ->substitutePageDocument ($ document , $ pageInformation ->getPageRecord (), $ indexQueueItem , $ tsfe );
230+ $ document = $ this ->substitutePageDocument (
231+ $ document ,
232+ $ pageInformation ->getPageRecord (),
233+ $ indexQueueItem ,
234+ $ tsfe ,
235+ );
222236
223237 $ this ->responseData ['pageIndexed ' ] = (int )$ this ->indexPage ($ document , $ indexQueueItem , $ tsfe );
224238 $ this ->responseData ['originalPageDocument ' ] = (array )$ document ;
@@ -236,14 +250,19 @@ protected function index(Item $indexQueueItem, ServerRequestInterface $request,
236250 /**
237251 * Gets the solr connection to use for indexing the page based on the
238252 * Index Queue item's properties.
253+ *
254+ * @throws DBALException
255+ * @throws NoSolrConnectionFoundException
256+ * @throws SolrException
257+ * @throws Throwable
239258 */
240259 protected function getSolrConnection (Item $ indexQueueItem , SiteLanguage $ siteLanguage , bool $ logExceptions ): SolrConnection
241260 {
242261 $ connectionManager = GeneralUtility::makeInstance (ConnectionManager::class);
243262 try {
244263 $ solrConnection = $ connectionManager ->getConnectionByRootPageId ($ indexQueueItem ->getRootPageUid (), $ siteLanguage ->getLanguageId ());
245264 if (!$ solrConnection ->getWriteService ()->ping ()) {
246- throw new Exception (
265+ throw new SolrException (
247266 'Could not connect to Solr server. ' ,
248267 1323946472
249268 );
@@ -269,9 +288,12 @@ protected function getSolrConnection(Item $indexQueueItem, SiteLanguage $siteLan
269288
270289 /**
271290 * This method retrieves the item from the index queue, that is indexed in this request.
291+ *
292+ * @throws DBALException
272293 */
273294 protected function getIndexQueueItem (): ?Item
274295 {
296+ /** @var Queue $indexQueue */
275297 $ indexQueue = GeneralUtility::makeInstance (Queue::class);
276298 return $ indexQueue ->getItem ($ this ->request ->getParameter ('item ' ));
277299 }
@@ -289,7 +311,13 @@ protected function substitutePageDocument(
289311 Item $ indexQueueItem ,
290312 TypoScriptFrontendController $ tsfe ,
291313 ): Document {
292- $ event = new AfterPageDocumentIsCreatedForIndexingEvent ($ pageDocument , $ indexQueueItem , $ pageRecord , $ tsfe , $ this ->configuration );
314+ $ event = new AfterPageDocumentIsCreatedForIndexingEvent (
315+ $ pageDocument ,
316+ $ indexQueueItem ,
317+ $ pageRecord ,
318+ $ tsfe ,
319+ $ this ->configuration ,
320+ );
293321 $ event = $ this ->getEventDispatcher ()->dispatch ($ event );
294322 return $ event ->getDocument ();
295323 }
@@ -309,6 +337,9 @@ protected function getPageDocument(TypoScriptFrontendController $tsfe, PageInfor
309337 * Indexes a page.
310338 *
311339 * @return bool TRUE after successfully indexing the page, FALSE on error
340+ *
341+ * @throws DBALException
342+ * @throws SolrException
312343 */
313344 protected function indexPage (
314345 Document $ pageDocument ,
@@ -336,6 +367,9 @@ protected function indexPage(
336367 * care of manipulating fields as defined in the field's configuration.
337368 *
338369 * @param Document[] $documents An array of documents to manipulate
370+ *
371+ * @throws SolrException
372+ * @throws DBALException
339373 */
340374 protected function processDocuments (array $ documents ): void
341375 {
0 commit comments