mirror of
https://github.com/Codappix/search_core.git
synced 2024-12-23 03:16:10 +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.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Core\Utility\ArrayUtility;
|
||||
|
||||
|
@ -61,7 +60,11 @@ class ConfigurationContainer implements ConfigurationContainerInterface
|
|||
*/
|
||||
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) {
|
||||
throw new InvalidArgumentException(
|
||||
|
|
|
@ -54,8 +54,8 @@ class Connection implements Singleton
|
|||
|
||||
if ($elasticaClient === null) {
|
||||
$elasticaClient = new \Elastica\Client([
|
||||
'host' => $this->configuration->getIfExists('connections.elasticsearch.host'),
|
||||
'port' => $this->configuration->getIfExists('connections.elasticsearch.port'),
|
||||
'host' => $this->configuration->get('connections.elasticsearch.host'),
|
||||
'port' => $this->configuration->get('connections.elasticsearch.port'),
|
||||
// TODO: Make configurable
|
||||
// 'log' => 'file',
|
||||
]);
|
||||
|
|
|
@ -127,55 +127,28 @@ abstract class AbstractIndexer implements IndexerInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $record
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function prepareRecord(array &$record)
|
||||
{
|
||||
try {
|
||||
$indexingConfiguration = $this->configuration->getIfExists(
|
||||
'indexing.' . $this->identifier . '.dataProcessing'
|
||||
);
|
||||
|
||||
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;
|
||||
foreach ($this->configuration->get('indexing.' . $this->identifier . '.dataProcessing') as $configuration) {
|
||||
$record = $this->dataProcessorService->executeDataProcessor($configuration, $record, $this->identifier);
|
||||
}
|
||||
} catch (InvalidArgumentException $e) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
$this->handleAbstract($record);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $record
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function handleAbstract(array &$record)
|
||||
{
|
||||
$record['search_abstract'] = '';
|
||||
|
||||
try {
|
||||
$indexConfiguration = $this->configuration->getIfExists(
|
||||
'indexing.' . $this->identifier . '.abstractFields'
|
||||
$fieldsToUse = GeneralUtility::trimExplode(
|
||||
',',
|
||||
$this->configuration->get('indexing.' . $this->identifier . '.abstractFields')
|
||||
);
|
||||
|
||||
$fieldsToUse = GeneralUtility::trimExplode(',', $indexConfiguration);
|
||||
if ($fieldsToUse === []) {
|
||||
return;
|
||||
}
|
||||
|
@ -185,14 +158,8 @@ abstract class AbstractIndexer implements IndexerInterface
|
|||
break;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
if ($e instanceof InvalidArgumentException) {
|
||||
return;
|
||||
} elseif ($e instanceof MissingArrayPathException) {
|
||||
return;
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ use Codappix\SearchCore\Configuration\InvalidArgumentException;
|
|||
use Codappix\SearchCore\Domain\Index\IndexerInterface;
|
||||
use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface;
|
||||
use TYPO3\CMS\Core\SingletonInterface as Singleton;
|
||||
use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
||||
|
||||
/**
|
||||
|
@ -66,10 +65,6 @@ class IndexerFactory implements Singleton
|
|||
// Nothing to do, we throw exception below
|
||||
} catch (InvalidArgumentException $e) {
|
||||
// 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);
|
||||
|
|
Loading…
Reference in a new issue