diff --git a/Classes/Configuration/ConfigurationContainer.php b/Classes/Configuration/ConfigurationContainer.php index 79227d5..764e91a 100644 --- a/Classes/Configuration/ConfigurationContainer.php +++ b/Classes/Configuration/ConfigurationContainer.php @@ -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( diff --git a/Classes/Connection/Elasticsearch/Connection.php b/Classes/Connection/Elasticsearch/Connection.php index a1ea999..a5e7d0f 100644 --- a/Classes/Connection/Elasticsearch/Connection.php +++ b/Classes/Connection/Elasticsearch/Connection.php @@ -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', ]); diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php index a6a8946..ce2335c 100644 --- a/Classes/Domain/Index/AbstractIndexer.php +++ b/Classes/Domain/Index/AbstractIndexer.php @@ -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; } } diff --git a/Classes/Domain/Index/IndexerFactory.php b/Classes/Domain/Index/IndexerFactory.php index c730854..668111d 100644 --- a/Classes/Domain/Index/IndexerFactory.php +++ b/Classes/Domain/Index/IndexerFactory.php @@ -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);