-
-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[!!!][FEATURE] Add new Events for Indexing
This change adds new PSR-14 events: * `ApacheSolrForTypo3\Solr\Event\Indexing\BeforePageDocumentIsProcessedForIndexingEvent` previously used with `$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPageAddDocuments']` * `ApacheSolrForTypo3\Solr\Event\Indexing\BeforeDocumentIsProcessedForIndexingEvent` previously used with `$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['preAddModifyDocuments']` * `ApacheSolrForTypo3\Solr\Event\Indexing\BeforeDocumentsAreIndexedEvent` previously used with `$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['indexItemAddDocuments']` This way, EXT:solr migrates to PSR-14 events and adds a more defined way to utilize the PHP API and to help extension authors to understand what is used in EXT:solr. The hooks * `$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['preAddModifyDocuments']` * `$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['indexItemAddDocuments']` * `$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPageAddDocuments']` are now removed in favor of the new events. These interfaces related to the hooks are removed: * `ApacheSolrForTypo3\Solr\IndexQueue\PageIndexerDocumentsModifier` * `ApacheSolrForTypo3\Solr\IndexQueue\AdditionalIndexQueueItemIndexer` * `ApacheSolrForTypo3\Solr\AdditionalPageIndexer` Documentation is added, tests are adapted. Relates: #3376, #3441 Fixes: #3437
- Loading branch information
Showing
24 changed files
with
535 additions
and
521 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
Classes/Event/Indexing/BeforeDocumentIsProcessedForIndexingEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace ApacheSolrForTypo3\Solr\Event\Indexing; | ||
|
||
use ApacheSolrForTypo3\Solr\IndexQueue\Item; | ||
use ApacheSolrForTypo3\Solr\System\Solr\Document\Document; | ||
use TYPO3\CMS\Core\Site\Entity\Site; | ||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage; | ||
|
||
/** | ||
* Allows third party extensions to provide additional documents which | ||
* should be indexed for the current item. | ||
* | ||
* Previously used with | ||
* $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['indexItemAddDocuments'] | ||
*/ | ||
class BeforeDocumentIsProcessedForIndexingEvent | ||
{ | ||
/** | ||
* @var Document[] | ||
*/ | ||
private array $documents = []; | ||
|
||
public function __construct( | ||
private readonly Document $document, | ||
private readonly Site $site, | ||
private readonly SiteLanguage $siteLanguage, | ||
private readonly Item $indexQueueItem | ||
) { | ||
$this->documents[] = $this->document; | ||
} | ||
|
||
public function getSite(): Site | ||
{ | ||
return $this->site; | ||
} | ||
|
||
public function getSiteLanguage(): SiteLanguage | ||
{ | ||
return $this->siteLanguage; | ||
} | ||
|
||
public function getIndexQueueItem(): Item | ||
{ | ||
return $this->indexQueueItem; | ||
} | ||
|
||
public function getDocument(): Document | ||
{ | ||
return $this->document; | ||
} | ||
|
||
/** | ||
* @param Document[] $documents | ||
*/ | ||
public function addDocuments(array $documents): void | ||
{ | ||
$this->documents = array_merge($this->documents, $documents); | ||
} | ||
|
||
/** | ||
* @return Document[] | ||
*/ | ||
public function getDocuments(): array | ||
{ | ||
return $this->documents; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace ApacheSolrForTypo3\Solr\Event\Indexing; | ||
|
||
use ApacheSolrForTypo3\Solr\IndexQueue\Item; | ||
use ApacheSolrForTypo3\Solr\System\Solr\Document\Document; | ||
use TYPO3\CMS\Core\Site\Entity\Site; | ||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage; | ||
|
||
/** | ||
* An event to manipulate documents right before they get added to the Solr index. | ||
* | ||
* Previously used with | ||
* $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['preAddModifyDocuments'] | ||
*/ | ||
class BeforeDocumentsAreIndexedEvent | ||
{ | ||
public function __construct( | ||
private readonly Document $document, | ||
private readonly Site $site, | ||
private readonly SiteLanguage $siteLanguage, | ||
private readonly Item $indexQueueItem, | ||
/** @var Document[] */ | ||
private array $documents, | ||
) { | ||
} | ||
|
||
public function getSite(): Site | ||
{ | ||
return $this->site; | ||
} | ||
|
||
public function getSiteLanguage(): SiteLanguage | ||
{ | ||
return $this->siteLanguage; | ||
} | ||
|
||
public function getIndexQueueItem(): Item | ||
{ | ||
return $this->indexQueueItem; | ||
} | ||
|
||
public function getDocument(): Document | ||
{ | ||
return $this->document; | ||
} | ||
|
||
/** | ||
* @param Document[] $documents | ||
*/ | ||
public function addDocuments(array $documents): void | ||
{ | ||
$this->documents = array_merge($this->documents, $documents); | ||
} | ||
|
||
/** | ||
* @return Document[] | ||
*/ | ||
public function getDocuments(): array | ||
{ | ||
return $this->documents; | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
Classes/Event/Indexing/BeforePageDocumentIsProcessedForIndexingEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace ApacheSolrForTypo3\Solr\Event\Indexing; | ||
|
||
use ApacheSolrForTypo3\Solr\IndexQueue\Item; | ||
use ApacheSolrForTypo3\Solr\System\Solr\Document\Document; | ||
use TYPO3\CMS\Core\Site\Entity\Site; | ||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage; | ||
|
||
/** | ||
* Allows to add more documents to the Solr index. | ||
* | ||
* Previously used with | ||
* $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPageAddDocuments'] | ||
*/ | ||
class BeforePageDocumentIsProcessedForIndexingEvent | ||
{ | ||
/** | ||
* @var Document[] | ||
*/ | ||
private array $documents = []; | ||
|
||
public function __construct( | ||
private readonly Document $document, | ||
private readonly Site $site, | ||
private readonly SiteLanguage $siteLanguage, | ||
private readonly Item $indexQueueItem | ||
) { | ||
$this->documents[] = $this->document; | ||
} | ||
|
||
public function getSite(): Site | ||
{ | ||
return $this->site; | ||
} | ||
|
||
public function getSiteLanguage(): SiteLanguage | ||
{ | ||
return $this->siteLanguage; | ||
} | ||
|
||
public function getIndexQueueItem(): Item | ||
{ | ||
return $this->indexQueueItem; | ||
} | ||
|
||
public function getDocument(): Document | ||
{ | ||
return $this->document; | ||
} | ||
|
||
/** | ||
* @param Document[] $documents | ||
*/ | ||
public function addDocuments(array $documents): void | ||
{ | ||
$this->documents = array_merge($this->documents, $documents); | ||
} | ||
|
||
/** | ||
* @return Document[] | ||
*/ | ||
public function getDocuments(): array | ||
{ | ||
return $this->documents; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.