TASK: Cleanup code

Use get and use an try catch. Receiving null through ifExists will
result in an php error.
This commit is contained in:
Daniel Siepmann 2017-07-27 13:00:51 +02:00
parent 7722c37ea5
commit 334bb34625
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -21,6 +21,7 @@ namespace Codappix\SearchCore\Domain\Index;
*/ */
use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use Codappix\SearchCore\Configuration\ConfigurationContainerInterface;
use Codappix\SearchCore\Configuration\InvalidArgumentException;
use Codappix\SearchCore\Connection\ConnectionInterface; use Codappix\SearchCore\Connection\ConnectionInterface;
use \TYPO3\CMS\Core\Utility\GeneralUtility; use \TYPO3\CMS\Core\Utility\GeneralUtility;
@ -125,18 +126,22 @@ abstract class AbstractIndexer implements IndexerInterface
{ {
$record['search_abstract'] = ''; $record['search_abstract'] = '';
$fieldsToUse = GeneralUtility::trimExplode( try {
',', $fieldsToUse = GeneralUtility::trimExplode(
$this->configuration->getIfExists('indexing.' . $this->identifier . '.abstractFields') ',',
); $this->configuration->get('indexing.' . $this->identifier . '.abstractFields')
if (!$fieldsToUse) { );
return; if (!$fieldsToUse) {
} return;
foreach ($fieldsToUse as $fieldToUse) {
if (isset($record[$fieldToUse]) && trim($record[$fieldToUse])) {
$record['search_abstract'] = trim($record[$fieldToUse]);
break;
} }
foreach ($fieldsToUse as $fieldToUse) {
if (isset($record[$fieldToUse]) && trim($record[$fieldToUse])) {
$record['search_abstract'] = trim($record[$fieldToUse]);
break;
}
}
} catch (InvalidArgumentException $e) {
return;
} }
} }