mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-23 01:36:11 +01:00
Revert changes to configuration fetching
Keep old code and behaviour. Adjust only a single place to keep old expected behaviour. If TYPO3 throws an exception, catch this, and replace it by old behaviour which is already handled throughout the code.
This commit is contained in:
parent
2b91425732
commit
5779cb911d
4 changed files with 16 additions and 51 deletions
|
@ -20,7 +20,6 @@ namespace Codappix\SearchCore\Configuration;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException;
|
|
||||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||||
use TYPO3\CMS\Core\Utility\ArrayUtility;
|
use TYPO3\CMS\Core\Utility\ArrayUtility;
|
||||||
|
|
||||||
|
@ -61,7 +60,11 @@ class ConfigurationContainer implements ConfigurationContainerInterface
|
||||||
*/
|
*/
|
||||||
public function get(string $path)
|
public function get(string $path)
|
||||||
{
|
{
|
||||||
$value = ArrayUtility::getValueByPath($this->settings, $path, '.');
|
try {
|
||||||
|
$value = ArrayUtility::getValueByPath($this->settings, $path, '.');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$value = null;
|
||||||
|
}
|
||||||
|
|
||||||
if ($value === null) {
|
if ($value === null) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
|
|
|
@ -54,8 +54,8 @@ class Connection implements Singleton
|
||||||
|
|
||||||
if ($elasticaClient === null) {
|
if ($elasticaClient === null) {
|
||||||
$elasticaClient = new \Elastica\Client([
|
$elasticaClient = new \Elastica\Client([
|
||||||
'host' => $this->configuration->getIfExists('connections.elasticsearch.host'),
|
'host' => $this->configuration->get('connections.elasticsearch.host'),
|
||||||
'port' => $this->configuration->getIfExists('connections.elasticsearch.port'),
|
'port' => $this->configuration->get('connections.elasticsearch.port'),
|
||||||
// TODO: Make configurable
|
// TODO: Make configurable
|
||||||
// 'log' => 'file',
|
// 'log' => 'file',
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -127,55 +127,28 @@ abstract class AbstractIndexer implements IndexerInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $record
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
protected function prepareRecord(array &$record)
|
protected function prepareRecord(array &$record)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$indexingConfiguration = $this->configuration->getIfExists(
|
foreach ($this->configuration->get('indexing.' . $this->identifier . '.dataProcessing') as $configuration) {
|
||||||
'indexing.' . $this->identifier . '.dataProcessing'
|
$record = $this->dataProcessorService->executeDataProcessor($configuration, $record, $this->identifier);
|
||||||
);
|
|
||||||
|
|
||||||
if (!empty($indexingConfiguration) && is_array($indexingConfiguration)) {
|
|
||||||
foreach ($indexingConfiguration as $configuration) {
|
|
||||||
$record = $this->dataProcessorService->executeDataProcessor(
|
|
||||||
$configuration,
|
|
||||||
$record,
|
|
||||||
$this->identifier
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
if ($e instanceof InvalidArgumentException) {
|
|
||||||
// Nothing to do
|
|
||||||
} elseif ($e instanceof MissingArrayPathException) {
|
|
||||||
// Nothing to do
|
|
||||||
} else {
|
|
||||||
throw $e;
|
|
||||||
}
|
}
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->handleAbstract($record);
|
$this->handleAbstract($record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $record
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
protected function handleAbstract(array &$record)
|
protected function handleAbstract(array &$record)
|
||||||
{
|
{
|
||||||
$record['search_abstract'] = '';
|
$record['search_abstract'] = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$indexConfiguration = $this->configuration->getIfExists(
|
$fieldsToUse = GeneralUtility::trimExplode(
|
||||||
'indexing.' . $this->identifier . '.abstractFields'
|
',',
|
||||||
|
$this->configuration->get('indexing.' . $this->identifier . '.abstractFields')
|
||||||
);
|
);
|
||||||
|
|
||||||
$fieldsToUse = GeneralUtility::trimExplode(',', $indexConfiguration);
|
|
||||||
if ($fieldsToUse === []) {
|
if ($fieldsToUse === []) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -185,14 +158,8 @@ abstract class AbstractIndexer implements IndexerInterface
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
if ($e instanceof InvalidArgumentException) {
|
return;
|
||||||
return;
|
|
||||||
} elseif ($e instanceof MissingArrayPathException) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ use Codappix\SearchCore\Configuration\InvalidArgumentException;
|
||||||
use Codappix\SearchCore\Domain\Index\IndexerInterface;
|
use Codappix\SearchCore\Domain\Index\IndexerInterface;
|
||||||
use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface;
|
use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface;
|
||||||
use TYPO3\CMS\Core\SingletonInterface as Singleton;
|
use TYPO3\CMS\Core\SingletonInterface as Singleton;
|
||||||
use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException;
|
|
||||||
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,10 +65,6 @@ class IndexerFactory implements Singleton
|
||||||
// Nothing to do, we throw exception below
|
// Nothing to do, we throw exception below
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
// Nothing to do, we throw exception below
|
// Nothing to do, we throw exception below
|
||||||
} catch (MissingArrayPathException $e) {
|
|
||||||
// Nothing to do, we throw exception below
|
|
||||||
} catch (\RuntimeException $exception) {
|
|
||||||
// Nothing to do, we throw exception below
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NoMatchingIndexerException('Could not find an indexer for ' . $identifier, 1497341442);
|
throw new NoMatchingIndexerException('Could not find an indexer for ' . $identifier, 1497341442);
|
||||||
|
|
Loading…
Reference in a new issue