Skip to content

Commit

Permalink
[TASK:T12] DI for IndexQueueWorkerTaskAdditionalFieldProvider::$siteR…
Browse files Browse the repository at this point in the history
…epository

Relates: TYPO3-Solr#3376
  • Loading branch information
dkd-kaehm committed Jun 1, 2023
1 parent d9e4f9d commit e5a2d57
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 72 deletions.
11 changes: 3 additions & 8 deletions Classes/Task/IndexQueueWorkerTaskAdditionalFieldProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@
*/
class IndexQueueWorkerTaskAdditionalFieldProvider extends AbstractAdditionalFieldProvider
{
/**
* SiteRepository
*/
protected SiteRepository $siteRepository;

public function __construct()
{
$this->siteRepository = GeneralUtility::makeInstance(SiteRepository::class);
public function __construct(
protected readonly SiteRepository $siteRepository
) {
}

/**
Expand Down
6 changes: 5 additions & 1 deletion Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ services:
event: TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent
# END: BE modules

viewhelper_backend:
viewHelpers_backend:
namespace: ApacheSolrForTypo3\Solr\ViewHelpers\Backend\
resource: '../Classes/ViewHelpers/Backend/*'
public: true
Expand Down Expand Up @@ -204,6 +204,10 @@ services:
- name: event.listener
identifier: 'solr.index.FrontendHelper.PageIndexer.indexPageContentAfterCacheableContentIsGenerated'
event: TYPO3\CMS\Frontend\Event\AfterCacheableContentIsGeneratedEvent
ApacheSolrForTypo3\Solr\Task\IndexQueueWorkerTaskAdditionalFieldProvider:
public: true
arguments:
$siteRepository: '@ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository'

### EXT:solr content objects
ApacheSolrForTypo3\Solr\ContentObject\Classification:
Expand Down
166 changes: 103 additions & 63 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
<?php

use ApacheSolrForTypo3\Solr\AdditionalFieldsIndexer;
use ApacheSolrForTypo3\Solr\Controller\SearchController;
use ApacheSolrForTypo3\Solr\Controller\SuggestController;
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\SearchResult;
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet;
use ApacheSolrForTypo3\Solr\Eid\ApiEid;
use ApacheSolrForTypo3\Solr\GarbageCollector;
use ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper\Manager as FrontendHelperManager;
use ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper\PageIndexer;
use ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper\UserGroupDetector;
use ApacheSolrForTypo3\Solr\IndexQueue\RecordMonitor;
use ApacheSolrForTypo3\Solr\Routing\Enhancer\SolrFacetMaskAndCombineEnhancer;
use ApacheSolrForTypo3\Solr\Search\AccessComponent;
use ApacheSolrForTypo3\Solr\Search\AnalysisComponent;
use ApacheSolrForTypo3\Solr\Search\DebugComponent;
use ApacheSolrForTypo3\Solr\Search\ElevationComponent;
use ApacheSolrForTypo3\Solr\Search\FacetingComponent;
use ApacheSolrForTypo3\Solr\Search\HighlightingComponent;
use ApacheSolrForTypo3\Solr\Search\LastSearchesComponent;
use ApacheSolrForTypo3\Solr\Search\RelevanceComponent;
use ApacheSolrForTypo3\Solr\Search\SearchComponentManager;
use ApacheSolrForTypo3\Solr\Search\SortingComponent;
use ApacheSolrForTypo3\Solr\Search\SpellcheckingComponent;
use ApacheSolrForTypo3\Solr\Search\StatisticsComponent;
use ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration;
use ApacheSolrForTypo3\Solr\Task\EventQueueWorkerTask;
use ApacheSolrForTypo3\Solr\Task\EventQueueWorkerTaskAdditionalFieldProvider;
use ApacheSolrForTypo3\Solr\Task\IndexQueueWorkerTask;
use ApacheSolrForTypo3\Solr\Task\IndexQueueWorkerTaskAdditionalFieldProvider;
use ApacheSolrForTypo3\Solr\Task\OptimizeIndexTask;
use ApacheSolrForTypo3\Solr\Task\OptimizeIndexTaskAdditionalFieldProvider;
use ApacheSolrForTypo3\Solr\Task\ReIndexTask;
use ApacheSolrForTypo3\Solr\Task\ReIndexTaskAdditionalFieldProvider;
use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Log\LogLevel;
use TYPO3\CMS\Core\Log\Writer\FileWriter;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
use TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask;

defined('TYPO3') or die('Access denied.');

Expand All @@ -21,111 +61,111 @@

// ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #
// registering Index Queue page indexer helpers
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPageSubstitutePageDocument'][\ApacheSolrForTypo3\Solr\AdditionalFieldsIndexer::class] = \ApacheSolrForTypo3\Solr\AdditionalFieldsIndexer::class;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPageSubstitutePageDocument'][AdditionalFieldsIndexer::class] = AdditionalFieldsIndexer::class;

\ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper\Manager::registerFrontendHelper(
FrontendHelperManager::registerFrontendHelper(
'findUserGroups',
\ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper\UserGroupDetector::class
UserGroupDetector::class
);

\ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper\Manager::registerFrontendHelper(
FrontendHelperManager::registerFrontendHelper(
'indexPage',
\ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper\PageIndexer::class
PageIndexer::class
);

// ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #

// register search components

\ApacheSolrForTypo3\Solr\Search\SearchComponentManager::registerSearchComponent(
SearchComponentManager::registerSearchComponent(
'access',
\ApacheSolrForTypo3\Solr\Search\AccessComponent::class
AccessComponent::class
);

\ApacheSolrForTypo3\Solr\Search\SearchComponentManager::registerSearchComponent(
SearchComponentManager::registerSearchComponent(
'relevance',
\ApacheSolrForTypo3\Solr\Search\RelevanceComponent::class
RelevanceComponent::class
);

\ApacheSolrForTypo3\Solr\Search\SearchComponentManager::registerSearchComponent(
SearchComponentManager::registerSearchComponent(
'sorting',
\ApacheSolrForTypo3\Solr\Search\SortingComponent::class
SortingComponent::class
);

\ApacheSolrForTypo3\Solr\Search\SearchComponentManager::registerSearchComponent(
SearchComponentManager::registerSearchComponent(
'debug',
\ApacheSolrForTypo3\Solr\Search\DebugComponent::class
DebugComponent::class
);

\ApacheSolrForTypo3\Solr\Search\SearchComponentManager::registerSearchComponent(
SearchComponentManager::registerSearchComponent(
'analysis',
\ApacheSolrForTypo3\Solr\Search\AnalysisComponent::class
AnalysisComponent::class
);

\ApacheSolrForTypo3\Solr\Search\SearchComponentManager::registerSearchComponent(
SearchComponentManager::registerSearchComponent(
'highlighting',
\ApacheSolrForTypo3\Solr\Search\HighlightingComponent::class
HighlightingComponent::class
);

\ApacheSolrForTypo3\Solr\Search\SearchComponentManager::registerSearchComponent(
SearchComponentManager::registerSearchComponent(
'spellchecking',
\ApacheSolrForTypo3\Solr\Search\SpellcheckingComponent::class
SpellcheckingComponent::class
);

\ApacheSolrForTypo3\Solr\Search\SearchComponentManager::registerSearchComponent(
SearchComponentManager::registerSearchComponent(
'faceting',
\ApacheSolrForTypo3\Solr\Search\FacetingComponent::class
FacetingComponent::class
);

\ApacheSolrForTypo3\Solr\Search\SearchComponentManager::registerSearchComponent(
SearchComponentManager::registerSearchComponent(
'statistics',
\ApacheSolrForTypo3\Solr\Search\StatisticsComponent::class
StatisticsComponent::class
);

\ApacheSolrForTypo3\Solr\Search\SearchComponentManager::registerSearchComponent(
SearchComponentManager::registerSearchComponent(
'lastSearches',
\ApacheSolrForTypo3\Solr\Search\LastSearchesComponent::class
LastSearchesComponent::class
);

\ApacheSolrForTypo3\Solr\Search\SearchComponentManager::registerSearchComponent(
SearchComponentManager::registerSearchComponent(
'elevation',
\ApacheSolrForTypo3\Solr\Search\ElevationComponent::class
ElevationComponent::class
);

// ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #

// adding scheduler tasks

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\ApacheSolrForTypo3\Solr\Task\OptimizeIndexTask::class] = [
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][OptimizeIndexTask::class] = [
'extension' => 'solr',
'title' => 'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:optimizeindex_title',
'description' => 'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:optimizeindex_description',
'additionalFields' => \ApacheSolrForTypo3\Solr\Task\OptimizeIndexTaskAdditionalFieldProvider::class,
'additionalFields' => OptimizeIndexTaskAdditionalFieldProvider::class,
];

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\ApacheSolrForTypo3\Solr\Task\ReIndexTask::class] = [
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][ReIndexTask::class] = [
'extension' => 'solr',
'title' => 'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:reindex_title',
'description' => 'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:reindex_description',
'additionalFields' => \ApacheSolrForTypo3\Solr\Task\ReIndexTaskAdditionalFieldProvider::class,
'additionalFields' => ReIndexTaskAdditionalFieldProvider::class,
];

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\ApacheSolrForTypo3\Solr\Task\IndexQueueWorkerTask::class] = [
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][IndexQueueWorkerTask::class] = [
'extension' => 'solr',
'title' => 'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:indexqueueworker_title',
'description' => 'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:indexqueueworker_description',
'additionalFields' => \ApacheSolrForTypo3\Solr\Task\IndexQueueWorkerTaskAdditionalFieldProvider::class,
'additionalFields' => IndexQueueWorkerTaskAdditionalFieldProvider::class,
];

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\ApacheSolrForTypo3\Solr\Task\EventQueueWorkerTask::class] = [
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][EventQueueWorkerTask::class] = [
'extension' => 'solr',
'title' => 'LLL:EXT:solr/Resources/Private/Language/locallang_be.xlf:task.eventQueueWorkerTask.title',
'description' => 'LLL:EXT:solr/Resources/Private/Language/locallang_be.xlf:task.eventQueueWorkerTask.description',
'additionalFields' => \ApacheSolrForTypo3\Solr\Task\EventQueueWorkerTaskAdditionalFieldProvider::class,
'additionalFields' => EventQueueWorkerTaskAdditionalFieldProvider::class,
];

if (!isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask::class]['options']['tables']['tx_solr_statistics'])) {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask::class]['options']['tables']['tx_solr_statistics'] = [
if (!isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][TableGarbageCollectionTask::class]['options']['tables']['tx_solr_statistics'])) {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][TableGarbageCollectionTask::class]['options']['tables']['tx_solr_statistics'] = [
'dateField' => 'tstamp',
'expirePeriod' => 180,
];
Expand All @@ -135,7 +175,7 @@

// registering the eID scripts
// TODO move to suggest form modifier
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_solr_api'] = \ApacheSolrForTypo3\Solr\Eid\ApiEid::class . '::main';
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_solr_api'] = ApiEid::class . '::main';

// ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #

Expand All @@ -150,7 +190,7 @@
}

if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_solr_configuration']['backend'])) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_solr_configuration']['backend'] = \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_solr_configuration']['backend'] = Typo3DatabaseBackend::class;
}

if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_solr_configuration']['options'])) {
Expand All @@ -163,13 +203,13 @@
}

// ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #
/** @var \ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration $extensionConfiguration */
$extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration::class
/** @var ExtensionConfiguration $extensionConfiguration */
$extensionConfiguration = GeneralUtility::makeInstance(
ExtensionConfiguration::class
);

// cacheHash handling
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(
ArrayUtility::mergeRecursiveWithOverrule(
$GLOBALS['TYPO3_CONF_VARS'],
[
'FE' => [
Expand All @@ -183,25 +223,25 @@
// ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #

if (!isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultClassName '])) {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultClassName '] = \ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\SearchResult::class;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultClassName '] = SearchResult::class;
}

if (!isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultSetClassName '])) {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultSetClassName '] = \ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet::class;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultSetClassName '] = SearchResultSet::class;
}

if (!isset($GLOBALS['TYPO3_CONF_VARS']['LOG']['ApacheSolrForTypo3']['Solr']['writerConfiguration'])) {
$context = \TYPO3\CMS\Core\Core\Environment::getContext();
$context = Environment::getContext();
if ($context->isProduction()) {
$logLevel = \TYPO3\CMS\Core\Log\LogLevel::ERROR;
$logLevel = LogLevel::ERROR;
} elseif ($context->isDevelopment()) {
$logLevel = \TYPO3\CMS\Core\Log\LogLevel::DEBUG;
$logLevel = LogLevel::DEBUG;
} else {
$logLevel = \TYPO3\CMS\Core\Log\LogLevel::INFO;
$logLevel = LogLevel::INFO;
}
$GLOBALS['TYPO3_CONF_VARS']['LOG']['ApacheSolrForTypo3']['Solr']['writerConfiguration'] = [
$logLevel => [
\TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
FileWriter::class => [
'logFileInfix' => 'solr',
],
],
Expand All @@ -210,44 +250,44 @@

// ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
ExtensionUtility::configurePlugin(
'Solr',
'pi_results',
[
\ApacheSolrForTypo3\Solr\Controller\SearchController::class => 'results,form,detail',
SearchController::class => 'results,form,detail',
],
[
\ApacheSolrForTypo3\Solr\Controller\SearchController::class => 'results',
SearchController::class => 'results',
]
);

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
ExtensionUtility::configurePlugin(
'Solr',
'pi_search',
[
\ApacheSolrForTypo3\Solr\Controller\SearchController::class => 'form',
SearchController::class => 'form',
]
);

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
ExtensionUtility::configurePlugin(
'Solr',
'pi_frequentlySearched',
[
\ApacheSolrForTypo3\Solr\Controller\SearchController::class => 'frequentlySearched',
SearchController::class => 'frequentlySearched',
],
[
\ApacheSolrForTypo3\Solr\Controller\SearchController::class => 'frequentlySearched',
SearchController::class => 'frequentlySearched',
]
);

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
ExtensionUtility::configurePlugin(
'Solr',
'pi_suggest',
[
\ApacheSolrForTypo3\Solr\Controller\SuggestController::class => 'suggest',
SuggestController::class => 'suggest',
],
[
\ApacheSolrForTypo3\Solr\Controller\SuggestController::class => 'suggest',
SuggestController::class => 'suggest',
]
);

Expand All @@ -258,7 +298,7 @@
* Solr route enhancer configuration
*/
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['enhancers']['SolrFacetMaskAndCombineEnhancer'] =
\ApacheSolrForTypo3\Solr\Routing\Enhancer\SolrFacetMaskAndCombineEnhancer::class;
SolrFacetMaskAndCombineEnhancer::class;

// add solr field to rootline fields
if ($GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] === '') {
Expand All @@ -271,6 +311,6 @@
$isComposerMode = defined('TYPO3_COMPOSER_MODE') && TYPO3_COMPOSER_MODE;
if (!$isComposerMode) {
// we load the autoloader for our libraries
$dir = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('solr');
$dir = ExtensionManagementUtility::extPath('solr');
require $dir . '/Resources/Private/Php/ComposerLibraries/vendor/autoload.php';
}

0 comments on commit e5a2d57

Please sign in to comment.