diff --git a/Classes/Command/Index/AbstractIndexCommand.php b/Classes/Command/Index/AbstractIndexCommand.php new file mode 100644 index 00000000..1de5f9f6 --- /dev/null +++ b/Classes/Command/Index/AbstractIndexCommand.php @@ -0,0 +1,25 @@ +indexingService = $objectManager->get(IndexingService::class); + } +} diff --git a/Classes/Command/Index/ResetCommand.php b/Classes/Command/Index/ResetCommand.php new file mode 100644 index 00000000..23f444db --- /dev/null +++ b/Classes/Command/Index/ResetCommand.php @@ -0,0 +1,33 @@ +setDescription('Reset search index') + ->addArgument('language', InputArgument::OPTIONAL, 'Language of index to reset'); + } + + /** + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->indexingService->resetIndex( + $input->hasArgument('language') ? (int)$input->getArgument('language') : null + ); + + return 0; + } +} diff --git a/Classes/Command/Index/SetupCommand.php b/Classes/Command/Index/SetupCommand.php new file mode 100644 index 00000000..4092ab9a --- /dev/null +++ b/Classes/Command/Index/SetupCommand.php @@ -0,0 +1,30 @@ +setDescription('Set up everything for search') + ->setHelp('Sets up indices and pipelines and verifies the indexer configuration, needs to be run after installation. Can be run multiple times to ensure correct setup.'); + } + + /** + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->indexingService->setup(); + + return 0; + } +} diff --git a/Classes/Command/Index/UpdateFullCommand.php b/Classes/Command/Index/UpdateFullCommand.php new file mode 100644 index 00000000..6b9e8816 --- /dev/null +++ b/Classes/Command/Index/UpdateFullCommand.php @@ -0,0 +1,31 @@ +setDescription('Process search indexers') + ->addArgument('type', InputArgument::OPTIONAL, 'Type to run indexers for'); + } + + /** + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->indexingService->indexFull($input->getArgument('type')); + + return 0; + } +} diff --git a/Classes/Command/Index/UpdatePartialCommand.php b/Classes/Command/Index/UpdatePartialCommand.php new file mode 100644 index 00000000..3eb73cb4 --- /dev/null +++ b/Classes/Command/Index/UpdatePartialCommand.php @@ -0,0 +1,31 @@ +setDescription('Process search indexer updates') + ->addArgument('type', InputArgument::OPTIONAL, 'Type to run indexers for'); + } + + /** + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->indexingService->indexPartial($input->getArgument('type')); + + return 0; + } +} diff --git a/Classes/Command/Legacy/AbstractLegacyCommand.php b/Classes/Command/Legacy/AbstractLegacyCommand.php new file mode 100644 index 00000000..a004df08 --- /dev/null +++ b/Classes/Command/Legacy/AbstractLegacyCommand.php @@ -0,0 +1,62 @@ +(deprecated)', + $this->getApplication()->find($this->replacementCommand)->getDescription() + ); + } + + /** + * @return \Symfony\Component\Console\Input\InputDefinition + */ + public function getDefinition() + { + return $this->getApplication()->find($this->replacementCommand)->getDefinition(); + } + + /** + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $deprecationMessage = sprintf( + 'The CLI command "%s" is deprecated and will be removed with Searchable v4, use "%s" instead', + $this->getName(), + $this->replacementCommand + ); + + if (!method_exists(GeneralUtility::class, 'deprecationLog')) { // TYPO3v10 + trigger_error($deprecationMessage, E_USER_DEPRECATED); + } else { + // @extensionScannerIgnoreLine + GeneralUtility::deprecationLog($deprecationMessage); + } + + return $this->getApplication()->find($this->replacementCommand)->run($input, $output); + } +} diff --git a/Classes/Command/Legacy/LegacyResetCommand.php b/Classes/Command/Legacy/LegacyResetCommand.php new file mode 100644 index 00000000..3ad8033a --- /dev/null +++ b/Classes/Command/Legacy/LegacyResetCommand.php @@ -0,0 +1,12 @@ +indexingService = $indexingService; - } - - /** - * Runs all indexers (full) - * @param string $type If set, only runs indexing for the given type - * @return void - */ - public function indexFullCommand($type = null) - { - $this->indexingService->indexFull($type); - } - - /** - * Runs all indexers (updates only) - * @param string $type If set, only runs indexing for the given type - * @return void - */ - public function indexPartialCommand($type = null) - { - $this->indexingService->indexPartial($type); - } - - /** - * Reset index for one or all languages - * - * @param int $language - * @return void - */ - public function resetIndexCommand($language = null) - { - $this->indexingService->resetIndex($language); - } - - /** - * Sets up everything, needs to be run after installation. - * Can be run multiple times to ensure correct setup. - * - * @return void - */ - public function setupCommand() - { - $this->indexingService->setup(); - } -} diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index 5894d4b6..5b0b8e4e 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -2,6 +2,7 @@ namespace PAGEmachine\Searchable\Controller; use PAGEmachine\Searchable\Connection; +use PAGEmachine\Searchable\Indexer\IndexerFactory; use PAGEmachine\Searchable\IndexManager; use PAGEmachine\Searchable\Search; use PAGEmachine\Searchable\Service\ExtconfService; @@ -17,11 +18,18 @@ class BackendController extends ActionController { /** - * @var \PAGEmachine\Searchable\Indexer\IndexerFactory - * @inject + * @var IndexerFactory $indexerFactory */ protected $indexerFactory; + /** + * @param IndexerFactory $indexerFactory + */ + public function injectIndexerFactory(IndexerFactory $indexerFactory): void + { + $this->indexerFactory = $indexerFactory; + } + /** * Backend Template Container * diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index 4a184390..92b24c39 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -1,6 +1,7 @@ searchQuery = $searchQuery; + } + public function initializeObject() { $this->searchQuery->setDefaultSettings($this->settings['search']); diff --git a/Classes/DataCollector/TcaDataCollector.php b/Classes/DataCollector/TcaDataCollector.php index b6d13ba6..996e08df 100644 --- a/Classes/DataCollector/TcaDataCollector.php +++ b/Classes/DataCollector/TcaDataCollector.php @@ -1,6 +1,7 @@ pageRepository = $pageRepository; + } + + /** + * @var ResolverManager $resolverManager */ protected $resolverManager; + /** + * @param ResolverManager $resolverManager + */ + public function injectResolverManager(ResolverManager $resolverManager): void + { + $this->resolverManager = $resolverManager; + } + /** * Holds one resolver for each subtype field * @var array diff --git a/Classes/Indexer/IndexerFactory.php b/Classes/Indexer/IndexerFactory.php index 219427c3..05227efd 100644 --- a/Classes/Indexer/IndexerFactory.php +++ b/Classes/Indexer/IndexerFactory.php @@ -4,6 +4,7 @@ use PAGEmachine\Searchable\Configuration\ConfigurationManager; use PAGEmachine\Searchable\Service\ExtconfService; use TYPO3\CMS\Core\SingletonInterface; +use TYPO3\CMS\Extbase\Object\ObjectManager; /* * This file is part of the PAGEmachine Searchable project. @@ -12,13 +13,18 @@ class IndexerFactory implements SingletonInterface { /** - * ObjectManager - * - * @var \TYPO3\CMS\Extbase\Object\ObjectManager - * @inject + * @var ObjectManager $objectManager */ protected $objectManager; + /** + * @param ObjectManager $objectManager + */ + public function injectObjectManager(ObjectManager $objectManager): void + { + $this->objectManager = $objectManager; + } + /** * Builds an array of indexers * diff --git a/Classes/Preview/FluidPreviewRenderer.php b/Classes/Preview/FluidPreviewRenderer.php index ed04c42a..f467015d 100644 --- a/Classes/Preview/FluidPreviewRenderer.php +++ b/Classes/Preview/FluidPreviewRenderer.php @@ -2,6 +2,7 @@ namespace PAGEmachine\Searchable\Preview; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; +use TYPO3\CMS\Fluid\View\StandaloneView; /* * This file is part of the PAGEmachine Searchable project. @@ -13,17 +14,31 @@ class FluidPreviewRenderer extends AbstractPreviewRenderer implements PreviewRendererInterface { /** - * @var \TYPO3\CMS\Fluid\View\StandaloneView - * @inject + * @var StandaloneView $view */ protected $view; /** - * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface - * @inject + * @param StandaloneView $view + */ + public function injectView(StandaloneView $view): void + { + $this->view = $view; + } + + /** + * @var ConfigurationManagerInterface $configurationManager */ protected $configurationManager; + /** + * @param ConfigurationManagerInterface $configurationManager + */ + public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void + { + $this->configurationManager = $configurationManager; + } + /** * @var array */ diff --git a/Classes/Utility/TsfeUtility.php b/Classes/Utility/TsfeUtility.php index 98e6f3ca..390528e8 100644 --- a/Classes/Utility/TsfeUtility.php +++ b/Classes/Utility/TsfeUtility.php @@ -24,7 +24,12 @@ public static function createTSFE() if (!is_object($GLOBALS['TSFE'])) { $GLOBALS['TSFE'] = GeneralUtility::makeInstance(TypoScriptFrontendController::class, $GLOBALS['TYPO3_CONF_VARS'], 1, ''); - $GLOBALS['TSFE']->connectToDB(); + + if (method_exists($GLOBALS['TSFE'], 'connectToDB')) { // TYPO3v9+ + // @extensionScannerIgnoreLine + $GLOBALS['TSFE']->connectToDB(); + } + $GLOBALS['TSFE']->initFEuser(); $GLOBALS['TSFE']->determineId(); $GLOBALS['TSFE']->initTemplate(); diff --git a/Configuration/Commands.php b/Configuration/Commands.php new file mode 100644 index 00000000..438a31ef --- /dev/null +++ b/Configuration/Commands.php @@ -0,0 +1,28 @@ + [ + 'class' => \PAGEmachine\Searchable\Command\Index\UpdateFullCommand::class, + ], + 'index:update:partial' => [ + 'class' => \PAGEmachine\Searchable\Command\Index\UpdatePartialCommand::class, + ], + 'index:reset' => [ + 'class' => \PAGEmachine\Searchable\Command\Index\ResetCommand::class, + ], + 'index:setup' => [ + 'class' => \PAGEmachine\Searchable\Command\Index\SetupCommand::class, + ], + 'searchable:indexfull' => [ + 'class' => \PAGEmachine\Searchable\Command\Legacy\LegacyUpdateFullCommand::class, + ], + 'searchable:indexpartial' => [ + 'class' => \PAGEmachine\Searchable\Command\Legacy\LegacyUpdatePartialCommand::class, + ], + 'searchable:resetindex' => [ + 'class' => \PAGEmachine\Searchable\Command\Legacy\LegacyResetCommand::class, + ], + 'searchable:setup' => [ + 'class' => \PAGEmachine\Searchable\Command\Legacy\LegacySetupCommand::class, + ], +]; diff --git a/ext_localconf.php b/ext_localconf.php index 31c92f19..58c0381f 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,13 +1,8 @@