FEATURE: Adjust configuration structure

* To support further configuration, specific to identifiers / tables.
* E.g. mapping and boost configuration should be possible.
* Adjust docs and settings.
* Adjust tests and code.
This commit is contained in:
Daniel Siepmann 2017-06-27 16:51:33 +02:00
parent 0136c10f12
commit 3553c443e2
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
10 changed files with 49 additions and 58 deletions

View file

@ -57,6 +57,9 @@ class IndexCommandController extends CommandController
{ {
// TODO: Allow to index multiple tables at once? // TODO: Allow to index multiple tables at once?
// TODO: Also allow to index everything? // TODO: Also allow to index everything?
// TODO: There is no test yet!
// TODO: Add test, adjust config path
if (! in_array($table, GeneralUtility::trimExplode(',', $this->configuration->get('indexer.tca.allowedTables')))) { if (! in_array($table, GeneralUtility::trimExplode(',', $this->configuration->get('indexer.tca.allowedTables')))) {
$this->outputLine('Table is not allowed for indexing.'); $this->outputLine('Table is not allowed for indexing.');
$this->quit(1); $this->quit(1);

View file

@ -151,7 +151,8 @@ class TcaTableService
. ' AND pages.no_search = 0' . ' AND pages.no_search = 0'
; ;
$userDefinedWhere = $this->configuration->getIfExists('indexer.tca.' . $this->tableName . '.additionalWhereClause'); // TODO: There is no test covering this option yet?
$userDefinedWhere = $this->configuration->getIfExists('indexing.' . $this->getTableName() . '.additionalWhereClause');
if (is_string($userDefinedWhere)) { if (is_string($userDefinedWhere)) {
$whereClause .= ' AND ' . $userDefinedWhere; $whereClause .= ' AND ' . $userDefinedWhere;
} }
@ -269,7 +270,7 @@ class TcaTableService
*/ */
protected function isBlackListedRootLineConfigured() protected function isBlackListedRootLineConfigured()
{ {
return (bool) $this->configuration->getIfExists('indexer.tca.rootLineBlacklist'); return (bool) $this->configuration->getIfExists('indexing.' . $this->getTableName() . '.rootLineBlacklist');
} }
/** /**
@ -279,6 +280,6 @@ class TcaTableService
*/ */
protected function getBlackListedRootLine() protected function getBlackListedRootLine()
{ {
return GeneralUtility::intExplode(',', $this->configuration->getIfExists('indexer.tca.rootLineBlacklist')); return GeneralUtility::intExplode(',', $this->configuration->getIfExists('indexing.' . $this->getTableName() . '.rootLineBlacklist'));
} }
} }

View file

@ -21,6 +21,7 @@ namespace Leonmrni\SearchCore\Domain\Service;
*/ */
use Leonmrni\SearchCore\Configuration\ConfigurationContainerInterface; use Leonmrni\SearchCore\Configuration\ConfigurationContainerInterface;
use Leonmrni\SearchCore\Domain\Index\TcaIndexer;
use TYPO3\CMS\Core\SingletonInterface as Singleton; use TYPO3\CMS\Core\SingletonInterface as Singleton;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
@ -86,7 +87,17 @@ class DataHandler implements Singleton
*/ */
public function getAllowedTablesForIndexing() public function getAllowedTablesForIndexing()
{ {
return GeneralUtility::trimExplode(',', $this->configuration->get('indexer.tca.allowedTables')); $tables = [];
foreach ($this->configuration->get('indexing') as $tableName => $indexConfiguration) {
if ($indexConfiguration['indexer'] === TcaIndexer::class) {
$tables[] = $tableName;
continue;
}
// TODO: Support custom indexer.
// Define "interface" / option which is used.
}
return $tables;
} }
/** /**

View file

@ -8,14 +8,11 @@ plugin {
} }
} }
indexer { indexing {
tca {
# Pages are not supported yet, see # Pages are not supported yet, see
# https://github.com/DanielSiepmann/search_core/issues/24 but # https://github.com/DanielSiepmann/search_core/issues/24 but
# should also be added, together with additionalWhereClause # should also be added, together with additionalWhereClause
# based on doktypes # based on doktypes
allowedTables = tt_content
tt_content { tt_content {
additionalWhereClause ( additionalWhereClause (
pages.doktype NOT IN (3, 199) pages.doktype NOT IN (3, 199)
@ -26,4 +23,3 @@ plugin {
} }
} }
} }
}

View file

@ -8,13 +8,10 @@ plugin {
} }
} }
indexer { indexing {
tca {
allowedTables = {$plugin.tx_searchcore.settings.indexer.tca.allowedTables}
tt_content { tt_content {
additionalWhereClause = {$plugin.tx_searchcore.settings.indexer.tca.tt_content.additionalWhereClause} indexer = Leonmrni\SearchCore\Domain\Index\TcaIndexer
} additionalWhereClause = {$plugin.tx_searchcore.settings.indexing.tt_content.additionalWhereClause}
} }
} }
} }

View file

@ -25,6 +25,6 @@ Indexing
-------- --------
The indexing is done by one of the available indexer. It should be possible to define the indexer to The indexing is done by one of the available indexer. It should be possible to define the indexer to
use for certein document types. Also it should be possible to write custom indexer to use. use for certain document types. Also it should be possible to write custom indexer to use.
Currently only the :ref:`TcaIndexer` is provided. Currently only the :ref:`TcaIndexer` is provided.

View file

@ -38,7 +38,7 @@ Options
The following section contains the different options, e.g. for :ref:`connections` and The following section contains the different options, e.g. for :ref:`connections` and
:ref:`indexer`: ``plugin.tx_searchcore.settings.connection`` or :ref:`indexer`: ``plugin.tx_searchcore.settings.connection`` or
``plugin.tx_searchcore.settings.index``. ``plugin.tx_searchcore.settings.indexing``.
.. _configuration_options_connection: .. _configuration_options_connection:
@ -106,8 +106,9 @@ Configured as::
plugin { plugin {
tx_searchcore { tx_searchcore {
settings { settings {
indexer { indexing {
indexerName { identifier {
indexer = Fully Qualified Classname
// the settings // the settings
} }
} }
@ -115,26 +116,10 @@ Configured as::
} }
} }
Where ``indexerName`` is one of the available :ref:`indexer`. Where ``identifier`` is up to you, but should match table names to make :ref:`TcaIndexer` work.
The following settings are available. For each setting its documented which indexer consumes it. The following settings are available. For each setting its documented which indexer consumes it.
.. _allowedTables:
``allowedTables``
"""""""""""""""""
Used by: :ref:`TcaIndexer`.
Defines which TYPO3 tables are allowed to be indexed. Only white listed tables will be processed
through Command Line Interface and Hooks.
Contains a comma separated list of table names. Spaces are trimmed.
Example::
plugin.tx_searchcore.settings.indexer.tca.allowedTables = tt_content, fe_users
.. _rootLineBlacklist: .. _rootLineBlacklist:
``rootLineBlacklist`` ``rootLineBlacklist``
@ -151,7 +136,7 @@ The following settings are available. For each setting its documented which inde
Example:: Example::
plugin.tx_searchcore.settings.index.tca.rootLineBlacklist = 3, 10, 100 plugin.tx_searchcore.settings.indexing.<identifier>.rootLineBlacklist = 3, 10, 100
Also it's possible to define some behaviour for the different document types. In context of TYPO3 Also it's possible to define some behaviour for the different document types. In context of TYPO3
tables are used as document types 1:1. It's possible to configure different tables. The following tables are used as document types 1:1. It's possible to configure different tables. The following
@ -170,7 +155,7 @@ options are available:
Example:: Example::
plugin.tx_searchcore.settings.index.tca.tt_content.additionalWhereClause = tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu') plugin.tx_searchcore.settings.indexing.<identifier>.additionalWhereClause = tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu')
.. attention:: .. attention::

View file

@ -8,9 +8,9 @@ plugin {
} }
} }
indexer { indexing {
tca { tt_content {
allowedTables = tt_content indexer = Leonmrni\SearchCore\Domain\Index\TcaIndexer
} }
} }
} }

View file

@ -1,8 +1,8 @@
plugin { plugin {
tx_searchcore { tx_searchcore {
settings { settings {
indexer { indexing {
tca { tt_content {
rootLineBlacklist = 3 rootLineBlacklist = 3
} }
} }

View file

@ -1,8 +1,7 @@
plugin { plugin {
tx_searchcore { tx_searchcore {
settings { settings {
indexer { indexing {
tca {
tt_content { tt_content {
additionalWhereClause = tt_content.CType NOT IN ('div') additionalWhereClause = tt_content.CType NOT IN ('div')
} }
@ -10,6 +9,5 @@ plugin {
} }
} }
} }
}
module.tx_searchcore < plugin.tx_searchcore module.tx_searchcore < plugin.tx_searchcore