diff --git a/Classes/Configuration/ConfigurationContainer.php b/Classes/Configuration/ConfigurationContainer.php index aaf0ebb..9dd954f 100644 --- a/Classes/Configuration/ConfigurationContainer.php +++ b/Classes/Configuration/ConfigurationContainer.php @@ -20,6 +20,7 @@ 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; @@ -60,16 +61,17 @@ class ConfigurationContainer implements ConfigurationContainerInterface */ public function get(string $path) { - $value = ArrayUtility::getValueByPath($this->settings, $path); - - if ($value === null) { + try + { + return ArrayUtility::getValueByPath($this->settings, $path); + } + catch (MissingArrayPathException $exception) + { throw new InvalidArgumentException( 'The given configuration option "' . $path . '" does not exist.', InvalidArgumentException::OPTION_DOES_NOT_EXIST ); } - - return $value; } /** @@ -78,6 +80,13 @@ class ConfigurationContainer implements ConfigurationContainerInterface */ public function getIfExists(string $path) { - return ArrayUtility::getValueByPath($this->settings, $path); + try + { + return ArrayUtility::getValueByPath($this->settings, $path); + } + catch (\Exception $exception) + { + return null; + } } } diff --git a/Classes/Connection/Elasticsearch/Connection.php b/Classes/Connection/Elasticsearch/Connection.php index a5e7d0f..a51b943 100644 --- a/Classes/Connection/Elasticsearch/Connection.php +++ b/Classes/Connection/Elasticsearch/Connection.php @@ -22,6 +22,7 @@ namespace Codappix\SearchCore\Connection\Elasticsearch; use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use TYPO3\CMS\Core\SingletonInterface as Singleton; +use TYPO3\CMS\Extbase\Utility\DebuggerUtility; /** * The current connection to elasticsearch. @@ -54,8 +55,8 @@ class Connection implements Singleton if ($elasticaClient === null) { $elasticaClient = new \Elastica\Client([ - 'host' => $this->configuration->get('connections.elasticsearch.host'), - 'port' => $this->configuration->get('connections.elasticsearch.port'), + 'host' => $this->configuration->getIfExists('connections.elasticsearch.host'), + 'port' => $this->configuration->getIfExists('connections.elasticsearch.port'), // TODO: Make configurable // 'log' => 'file', ]); diff --git a/Classes/Domain/Index/IndexerFactory.php b/Classes/Domain/Index/IndexerFactory.php index 668111d..f59632f 100644 --- a/Classes/Domain/Index/IndexerFactory.php +++ b/Classes/Domain/Index/IndexerFactory.php @@ -25,6 +25,7 @@ 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; /** @@ -65,6 +66,8 @@ 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 } throw new NoMatchingIndexerException('Could not find an indexer for ' . $identifier, 1497341442);