first commit

This commit is contained in:
Sven Wappler
2021-04-17 21:20:54 +02:00
parent c93ec9492a
commit cadcc8edb4
406 changed files with 4917 additions and 5157 deletions

View File

@@ -29,9 +29,9 @@ use WapplerSystems\Meilisearch\Access\Rootline;
use WapplerSystems\Meilisearch\ConnectionManager;
use WapplerSystems\Meilisearch\IndexQueue\Item;
use WapplerSystems\Meilisearch\IndexQueue\Queue;
use WapplerSystems\Meilisearch\NoSolrConnectionFoundException;
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
use WapplerSystems\Meilisearch\System\Solr\SolrConnection;
use WapplerSystems\Meilisearch\NoMeilisearchConnectionFoundException;
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
use WapplerSystems\Meilisearch\System\Meilisearch\MeilisearchConnection;
use WapplerSystems\Meilisearch\Typo3PageIndexer;
use WapplerSystems\Meilisearch\Util;
use Exception;
@@ -91,7 +91,7 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageIndexing'][__CLASS__] = $pageIndexingHookRegistration;
// indexes fields defined in plugin.tx_meilisearch.index.queue.pages.fields
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPageSubstitutePageDocument'][PageFieldMappingIndexer::class] = PageFieldMappingIndexer::class;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['Indexer']['indexPageSubstitutePageDocument'][PageFieldMappingIndexer::class] = PageFieldMappingIndexer::class;
$this->registerAuthorizationService();
}
@@ -170,13 +170,13 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
$overrulingPriority = $this->getHighestAuthenticationServicePriority() + 1;
ExtensionManagementUtility::addService(
'solr', // extension key
'meilisearch', // extension key
'auth', // service type
AuthorizationService::class,
// service key
[// service meta data
'title' => 'Solr Indexer Authorization',
'description' => 'Authorizes the Solr Index Queue indexer to access protected pages.',
'title' => 'Meilisearch Indexer Authorization',
'description' => 'Authorizes the Meilisearch Index Queue indexer to access protected pages.',
'subtype' => 'getUserFE,authUserFE,getGroupsFE',
@@ -187,7 +187,7 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
'os' => '',
'exec' => '',
'classFile' => ExtensionManagementUtility::extPath('solr') . 'Classes/IndexQueue/FrontendHelper/AuthorizationService.php',
'classFile' => ExtensionManagementUtility::extPath('meilisearch') . 'Classes/IndexQueue/FrontendHelper/AuthorizationService.php',
'className' => AuthorizationService::class,
]
);
@@ -263,16 +263,16 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
*/
public function hook_indexContent(TypoScriptFrontendController $page)
{
$this->logger = GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
$this->logger = GeneralUtility::makeInstance(MeilisearchLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
$this->page = $page;
$configuration = Util::getSolrConfiguration();
$configuration = Util::getMeilisearchConfiguration();
$logPageIndexed = $configuration->getLoggingIndexingPageIndexed();
if (!$this->page->config['config']['index_enable']) {
if ($logPageIndexed) {
$this->logger->log(
SolrLogManager::ERROR,
MeilisearchLogManager::ERROR,
'Indexing is disabled. Set config.index_enable = 1 .'
);
}
@@ -285,32 +285,32 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
throw new UnexpectedValueException('Can not get index queue item', 1482162337);
}
$solrConnection = $this->getSolrConnection($indexQueueItem);
$meilisearchConnection = $this->getMeilisearchConnection($indexQueueItem);
/** @var $indexer Typo3PageIndexer */
$indexer = GeneralUtility::makeInstance(Typo3PageIndexer::class, /** @scrutinizer ignore-type */ $page);
$indexer->setSolrConnection($solrConnection);
$indexer->setMeilisearchConnection($meilisearchConnection);
$indexer->setPageAccessRootline($this->getAccessRootline());
$indexer->setPageUrl($this->generatePageUrl());
$indexer->setMountPointParameter($GLOBALS['TSFE']->MP);
$indexer->setIndexQueueItem($indexQueueItem);
$this->responseData['pageIndexed'] = (int)$indexer->indexPage();
$this->responseData['originalPageDocument'] = (array)$indexer->getPageSolrDocument();
$this->responseData['solrConnection'] = [
$this->responseData['originalPageDocument'] = (array)$indexer->getPageMeilisearchDocument();
$this->responseData['meilisearchConnection'] = [
'rootPage' => $indexQueueItem->getRootPageUid(),
'sys_language_uid' => Util::getLanguageUid(),
'solr' => (string)$solrConnection->getNode('write')
'meilisearch' => (string)$meilisearchConnection->getNode('write')
];
$documentsSentToSolr = $indexer->getDocumentsSentToSolr();
foreach ($documentsSentToSolr as $document) {
$this->responseData['documentsSentToSolr'][] = (array)$document;
$documentsSentToMeilisearch = $indexer->getDocumentsSentToMeilisearch();
foreach ($documentsSentToMeilisearch as $document) {
$this->responseData['documentsSentToMeilisearch'][] = (array)$document;
}
} catch (Exception $e) {
if ($configuration->getLoggingExceptions()) {
$this->logger->log(
SolrLogManager::ERROR,
MeilisearchLogManager::ERROR,
'Exception while trying to index page ' . $page->id,
[
$e->__toString()
@@ -321,7 +321,7 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
if ($logPageIndexed) {
$success = $this->responseData['pageIndexed'] ? 'Success' : 'Failed';
$severity = $this->responseData['pageIndexed'] ? SolrLogManager::NOTICE : SolrLogManager::ERROR;
$severity = $this->responseData['pageIndexed'] ? MeilisearchLogManager::NOTICE : MeilisearchLogManager::ERROR;
$this->logger->log(
$severity,
@@ -332,14 +332,14 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
}
/**
* Gets the solr connection to use for indexing the page based on the
* Gets the meilisearch connection to use for indexing the page based on the
* Index Queue item's properties.
*
* @param Item $indexQueueItem
* @return SolrConnection Solr server connection
* @throws NoSolrConnectionFoundException
* @return MeilisearchConnection Meilisearch server connection
* @throws NoMeilisearchConnectionFoundException
*/
protected function getSolrConnection(Item $indexQueueItem)
protected function getMeilisearchConnection(Item $indexQueueItem)
{
/** @var $connectionManager ConnectionManager */
$connectionManager = GeneralUtility::makeInstance(ConnectionManager::class);