mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-26 07:56:12 +01:00
[task] handle missing array path exceptions
This commit is contained in:
parent
01e2179b14
commit
5ea0f34632
3 changed files with 21 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
]);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue