mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-26 03:16:11 +01:00
[TASK] bugfixes and error removal
This commit is contained in:
parent
f936d1f7c5
commit
0a9cdd5dce
3 changed files with 83 additions and 44 deletions
|
@ -20,8 +20,10 @@ 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;
|
||||||
|
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container of all configurations for extension.
|
* Container of all configurations for extension.
|
||||||
|
@ -60,7 +62,7 @@ class ConfigurationContainer implements ConfigurationContainerInterface
|
||||||
*/
|
*/
|
||||||
public function get(string $path)
|
public function get(string $path)
|
||||||
{
|
{
|
||||||
$value = ArrayUtility::getValueByPath($this->settings, $path);
|
$value = ArrayUtility::getValueByPath($this->settings, $path, '.');
|
||||||
|
|
||||||
if ($value === null) {
|
if ($value === null) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
|
@ -78,6 +80,10 @@ class ConfigurationContainer implements ConfigurationContainerInterface
|
||||||
*/
|
*/
|
||||||
public function getIfExists(string $path)
|
public function getIfExists(string $path)
|
||||||
{
|
{
|
||||||
return ArrayUtility::getValueByPath($this->settings, $path);
|
try {
|
||||||
|
return ArrayUtility::getValueByPath($this->settings, $path, '.');
|
||||||
|
} catch (MissingArrayPathException $exception) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Codappix\SearchCore\Domain\Index;
|
namespace Codappix\SearchCore\Domain\Index;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -23,6 +24,8 @@ namespace Codappix\SearchCore\Domain\Index;
|
||||||
use Codappix\SearchCore\Configuration\ConfigurationContainerInterface;
|
use Codappix\SearchCore\Configuration\ConfigurationContainerInterface;
|
||||||
use Codappix\SearchCore\Configuration\InvalidArgumentException;
|
use Codappix\SearchCore\Configuration\InvalidArgumentException;
|
||||||
use Codappix\SearchCore\Connection\ConnectionInterface;
|
use Codappix\SearchCore\Connection\ConnectionInterface;
|
||||||
|
use TYPO3\CMS\Core\Exception;
|
||||||
|
use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
|
|
||||||
abstract class AbstractIndexer implements IndexerInterface
|
abstract class AbstractIndexer implements IndexerInterface
|
||||||
|
@ -125,28 +128,51 @@ abstract class AbstractIndexer implements IndexerInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $record
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
protected function prepareRecord(array &$record)
|
protected function prepareRecord(array &$record)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
foreach ($this->configuration->get('indexing.' . $this->identifier . '.dataProcessing') as $configuration) {
|
$indexingConfiguration = $this->configuration->get('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 {
|
||||||
$fieldsToUse = GeneralUtility::trimExplode(
|
|
||||||
',',
|
$indexConfiguration = $this->configuration->get('indexing.' . $this->identifier . '.abstractFields');
|
||||||
$this->configuration->get('indexing.' . $this->identifier . '.abstractFields')
|
|
||||||
);
|
$fieldsToUse = GeneralUtility::trimExplode(',', $indexConfiguration);
|
||||||
if ($fieldsToUse === []) {
|
if ($fieldsToUse === []) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -156,8 +182,14 @@ abstract class AbstractIndexer implements IndexerInterface
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (\Exception $e) {
|
||||||
|
if ($e instanceof InvalidArgumentException) {
|
||||||
return;
|
return;
|
||||||
|
} elseif ($e instanceof MissingArrayPathException) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,12 +42,13 @@ call_user_func(
|
||||||
|
|
||||||
\Codappix\SearchCore\Compatibility\ImplementationRegistrationService::registerImplementations();
|
\Codappix\SearchCore\Compatibility\ImplementationRegistrationService::registerImplementations();
|
||||||
|
|
||||||
|
|
||||||
// API does make use of object manager, therefore use GLOBALS
|
// API does make use of object manager, therefore use GLOBALS
|
||||||
$extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get($extensionKey);
|
$extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get($extensionKey);
|
||||||
|
|
||||||
if ($extensionConfiguration === false
|
if ($extensionConfiguration === false
|
||||||
|| !isset($extensionConfiguration['disable.']['elasticsearch'])
|
|| !isset($extensionConfiguration['disable']['elasticsearch'])
|
||||||
|| $extensionConfiguration['disable.']['elasticsearch'] !== '1'
|
|| $extensionConfiguration['disable']['elasticsearch'] !== '1'
|
||||||
) {
|
) {
|
||||||
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class)
|
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class)
|
||||||
->registerImplementation(
|
->registerImplementation(
|
||||||
|
|
Loading…
Reference in a new issue