mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-26 08:16:12 +01:00
Merge branch 'feature/small-improvements' into feature/cms-8-support
This commit is contained in:
commit
0fa05270d5
2 changed files with 10 additions and 36 deletions
|
@ -61,7 +61,10 @@ class DocumentFactory implements Singleton
|
||||||
$identifier = $document['search_identifier'];
|
$identifier = $document['search_identifier'];
|
||||||
unset($document['search_identifier']);
|
unset($document['search_identifier']);
|
||||||
|
|
||||||
$this->logger->debug('Convert document to document', [$identifier, $document]);
|
$this->logger->debug(
|
||||||
|
sprintf('Convert %s %u to document.', $documentType, $identifier),
|
||||||
|
[$identifier, $document]
|
||||||
|
);
|
||||||
return new \Elastica\Document($identifier, $document);
|
return new \Elastica\Document($identifier, $document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,6 @@ namespace Codappix\SearchCore\Domain\Index\TcaIndexer;
|
||||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||||
use TYPO3\CMS\Core\SingletonInterface as Singleton;
|
use TYPO3\CMS\Core\SingletonInterface as Singleton;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
|
|
||||||
|
|
||||||
use TYPO3\CMS\Backend\Form\FormDataCompiler;
|
|
||||||
use TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves relations from TCA using TCA.
|
* Resolves relations from TCA using TCA.
|
||||||
|
@ -36,12 +32,6 @@ use TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord;
|
||||||
*/
|
*/
|
||||||
class RelationResolver implements Singleton
|
class RelationResolver implements Singleton
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Resolve relations for the given record.
|
|
||||||
*
|
|
||||||
* @param TcaTableService $service
|
|
||||||
* @param array $record
|
|
||||||
*/
|
|
||||||
public function resolveRelationsForRecord(TcaTableService $service, array &$record) : void
|
public function resolveRelationsForRecord(TcaTableService $service, array &$record) : void
|
||||||
{
|
{
|
||||||
foreach (array_keys($record) as $column) {
|
foreach (array_keys($record) as $column) {
|
||||||
|
@ -59,38 +49,27 @@ class RelationResolver implements Singleton
|
||||||
}
|
}
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
// Column is not configured.
|
// Column is not configured.
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve the given value from TYPO3 API response.
|
|
||||||
*
|
|
||||||
* @param mixed $value The value from FormEngine to resolve.
|
|
||||||
* @param array $tcaColumn The tca config of the relation.
|
|
||||||
*
|
|
||||||
* @return array<String>|string
|
|
||||||
*/
|
|
||||||
protected function resolveValue($value, array $tcaColumn)
|
protected function resolveValue($value, array $tcaColumn)
|
||||||
{
|
{
|
||||||
if ($value === '') {
|
if ($value === '' || $value === 'N/A') {
|
||||||
return '';
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tcaColumn['type'] === 'select') {
|
if ($tcaColumn['type'] === 'select' && strpos($value, ';') !== false) {
|
||||||
return $this->resolveForeignDbValue($value);
|
return $this->resolveForeignDbValue($value);
|
||||||
}
|
}
|
||||||
if ($tcaColumn['type'] === 'inline' || $tcaColumn['type'] === 'group') {
|
if (in_array($tcaColumn['type'], ['inline', 'group', 'select'])) {
|
||||||
return $this->resolveInlineValue($value);
|
return $this->resolveInlineValue($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array Column config.
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function isRelation(array &$config) : bool
|
protected function isRelation(array &$config) : bool
|
||||||
{
|
{
|
||||||
return isset($config['foreign_table'])
|
return isset($config['foreign_table'])
|
||||||
|
@ -99,16 +78,8 @@ class RelationResolver implements Singleton
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $value
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function resolveForeignDbValue(string $value) : array
|
protected function resolveForeignDbValue(string $value) : array
|
||||||
{
|
{
|
||||||
if ($value === 'N/A') {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return array_map('trim', explode(';', $value));
|
return array_map('trim', explode(';', $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue