first commit
This commit is contained in:
@@ -32,7 +32,7 @@ use WapplerSystems\Meilisearch\FrontendEnvironment;
|
||||
use WapplerSystems\Meilisearch\GarbageCollector;
|
||||
use WapplerSystems\Meilisearch\System\Configuration\ExtensionConfiguration;
|
||||
use WapplerSystems\Meilisearch\System\Configuration\TypoScriptConfiguration;
|
||||
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Records\Pages\PagesRepository;
|
||||
use WapplerSystems\Meilisearch\System\TCA\TCAService;
|
||||
use WapplerSystems\Meilisearch\Util;
|
||||
@@ -83,7 +83,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
protected $pagesRepository;
|
||||
|
||||
/**
|
||||
* @var SolrLogManager
|
||||
* @var MeilisearchLogManager
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
@@ -100,7 +100,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
* @param TCAService|null $TCAService
|
||||
* @param RootPageResolver $rootPageResolver
|
||||
* @param PagesRepository|null $pagesRepository
|
||||
* @param SolrLogManager|null $solrLogManager
|
||||
* @param MeilisearchLogManager|null $meilisearchLogManager
|
||||
* @param ConfigurationAwareRecordService|null $recordService
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -109,7 +109,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
TCAService $TCAService = null,
|
||||
RootPageResolver $rootPageResolver = null,
|
||||
PagesRepository $pagesRepository = null,
|
||||
SolrLogManager $solrLogManager = null,
|
||||
MeilisearchLogManager $meilisearchLogManager = null,
|
||||
ConfigurationAwareRecordService $recordService = null,
|
||||
FrontendEnvironment $frontendEnvironment = null
|
||||
)
|
||||
@@ -120,14 +120,14 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
$this->tcaService = $TCAService ?? GeneralUtility::makeInstance(TCAService::class);
|
||||
$this->rootPageResolver = $rootPageResolver ?? GeneralUtility::makeInstance(RootPageResolver::class);
|
||||
$this->pagesRepository = $pagesRepository ?? GeneralUtility::makeInstance(PagesRepository::class);
|
||||
$this->logger = $solrLogManager ?? GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->logger = $meilisearchLogManager ?? GeneralUtility::makeInstance(MeilisearchLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->frontendEnvironment = $frontendEnvironment ?? GeneralUtility::makeInstance(FrontendEnvironment::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SolrLogManager $logger
|
||||
* @param MeilisearchLogManager $logger
|
||||
*/
|
||||
public function setLogger(SolrLogManager $logger)
|
||||
public function setLogger(MeilisearchLogManager $logger)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
@@ -248,8 +248,8 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
*/
|
||||
protected function applyPageChangesToQueue($uid)
|
||||
{
|
||||
$solrConfiguration = $this->getSolrConfigurationFromPageId($uid);
|
||||
$record = $this->configurationAwareRecordService->getRecord('pages', $uid, $solrConfiguration);
|
||||
$meilisearchConfiguration = $this->getMeilisearchConfigurationFromPageId($uid);
|
||||
$record = $this->configurationAwareRecordService->getRecord('pages', $uid, $meilisearchConfiguration);
|
||||
if (!empty($record) && $this->tcaService->isEnabledRecord('pages', $record)) {
|
||||
$this->mountPageUpdater->update($uid);
|
||||
$this->indexQueue->updateItem('pages', $uid);
|
||||
@@ -268,11 +268,11 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
*/
|
||||
protected function applyRecordChangesToQueue($table, $uid, $pid)
|
||||
{
|
||||
$solrConfiguration = $this->getSolrConfigurationFromPageId($pid);
|
||||
$isMonitoredTable = $solrConfiguration->getIndexQueueIsMonitoredTable($table);
|
||||
$meilisearchConfiguration = $this->getMeilisearchConfigurationFromPageId($pid);
|
||||
$isMonitoredTable = $meilisearchConfiguration->getIndexQueueIsMonitoredTable($table);
|
||||
|
||||
if ($isMonitoredTable) {
|
||||
$record = $this->configurationAwareRecordService->getRecord($table, $uid, $solrConfiguration);
|
||||
$record = $this->configurationAwareRecordService->getRecord($table, $uid, $meilisearchConfiguration);
|
||||
|
||||
if (!empty($record) && $this->tcaService->isEnabledRecord($table, $record)) {
|
||||
$uid = $this->tcaService->getTranslationOriginalUidIfTranslated($table, $record, $uid);
|
||||
@@ -287,7 +287,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
/**
|
||||
* Hooks into TCE Main and watches all record creations and updates. If it
|
||||
* detects that the new/updated record belongs to a table configured for
|
||||
* indexing through Solr, we add the record to the index queue.
|
||||
* indexing through Meilisearch, we add the record to the index queue.
|
||||
*
|
||||
* @param string $status Status of the current operation, 'new' or 'update'
|
||||
* @param string $table The table the record belongs to
|
||||
@@ -324,7 +324,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
$this->processRecord($recordTable, $recordPageId, $recordUid, $fields);
|
||||
} catch (NoPidException $e) {
|
||||
$message = 'Record without valid pid was processed ' . $table . ':' . $uid;
|
||||
$this->logger->log(SolrLogManager::WARNING, $message);
|
||||
$this->logger->log(MeilisearchLogManager::WARNING, $message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,14 +380,14 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
}
|
||||
}
|
||||
foreach ($rootPageIds as $configurationPageId) {
|
||||
$solrConfiguration = $this->getSolrConfigurationFromPageId($configurationPageId);
|
||||
$isMonitoredRecord = $solrConfiguration->getIndexQueueIsMonitoredTable($recordTable);
|
||||
$meilisearchConfiguration = $this->getMeilisearchConfigurationFromPageId($configurationPageId);
|
||||
$isMonitoredRecord = $meilisearchConfiguration->getIndexQueueIsMonitoredTable($recordTable);
|
||||
if (!$isMonitoredRecord) {
|
||||
// when it is a non monitored record, we can skip it.
|
||||
continue;
|
||||
}
|
||||
|
||||
$record = $this->configurationAwareRecordService->getRecord($recordTable, $recordUid, $solrConfiguration);
|
||||
$record = $this->configurationAwareRecordService->getRecord($recordTable, $recordUid, $meilisearchConfiguration);
|
||||
if (empty($record)) {
|
||||
// TODO move this part to the garbage collector
|
||||
// check if the item should be removed from the index because it no longer matches the conditions
|
||||
@@ -514,7 +514,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes record from the index queue and from the solr index
|
||||
* Removes record from the index queue and from the meilisearch index
|
||||
*
|
||||
* @param string $recordTable Name of table where the record lives
|
||||
* @param int $recordUid Id of record
|
||||
@@ -526,7 +526,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes record from the index queue and from the solr index when the item is in the queue.
|
||||
* Removes record from the index queue and from the meilisearch index when the item is in the queue.
|
||||
*
|
||||
* @param string $recordTable Name of table where the record lives
|
||||
* @param int $recordUid Id of record
|
||||
@@ -594,8 +594,8 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
* @param int $language
|
||||
* @return TypoScriptConfiguration
|
||||
*/
|
||||
protected function getSolrConfigurationFromPageId($pageId)
|
||||
protected function getMeilisearchConfigurationFromPageId($pageId)
|
||||
{
|
||||
return $this->frontendEnvironment->getSolrConfigurationFromPageId($pageId);
|
||||
return $this->frontendEnvironment->getMeilisearchConfigurationFromPageId($pageId);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user