FEATURE: Add new feature to cli

This commit is contained in:
Daniel Siepmann 2016-12-15 14:10:04 +01:00
parent 541c6db53a
commit 28ef07cbd7
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -21,6 +21,7 @@ namespace Leonmrni\SearchCore\Command;
*/ */
use Leonmrni\SearchCore\Domain\Index\IndexerFactory; use Leonmrni\SearchCore\Domain\Index\IndexerFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\CommandController; use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
/** /**
@ -33,6 +34,12 @@ class IndexCommandController extends CommandController
*/ */
protected $indexerFactory; protected $indexerFactory;
/**
* @var \Leonmrni\SearchCore\Configuration\ConfigurationContainerInterface
* @inject
*/
protected $configuration;
/** /**
* @param IndexerFactory $factory * @param IndexerFactory $factory
*/ */
@ -50,6 +57,11 @@ 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?
if (! in_array($table, GeneralUtility::trimExplode(',', $this->configuration->get('index', 'allowedTables')))) {
$this->outputLine('Table is not allowed for indexing.');
$this->quit(1);
}
$this->indexerFactory->getIndexer($table)->indexAllDocuments(); $this->indexerFactory->getIndexer($table)->indexAllDocuments();
$this->outputLine('Table was indexed.');
} }
} }