Skip to content
Snippets Groups Projects

Fix dev

Merged Christian Mahnke requested to merge fix-dev into dev
1 file
+ 31
29
Compare changes
  • Side-by-side
  • Inline
@@ -10,7 +10,7 @@ use FOS\ElasticaBundle\Elastica\Client;
@@ -10,7 +10,7 @@ use FOS\ElasticaBundle\Elastica\Client;
class ChildCollectionsMappingTransformer extends GeonamesEnrichTransformer
class ChildCollectionsMappingTransformer extends GeonamesEnrichTransformer
{
{
protected array $fieldMappings;
protected array $fieldMappings;
protected array $nestedMappings;
protected array $nestedMappings = [];
public function __construct(Client $client, string $geonamesIndex, array $settings)
public function __construct(Client $client, string $geonamesIndex, array $settings)
{
{
@@ -77,37 +77,39 @@ class ChildCollectionsMappingTransformer extends GeonamesEnrichTransformer
@@ -77,37 +77,39 @@ class ChildCollectionsMappingTransformer extends GeonamesEnrichTransformer
$filteredFields = self::filterFields($fields, self::extractFilterFields($entityFieldMappings));
$filteredFields = self::filterFields($fields, self::extractFilterFields($entityFieldMappings));
//Filter nested
//Filter nested
$filteredNestedDocs = [];
$filteredNestedDocs = [];
foreach ($filteredFields as $key => $mapping) {
if (!empty($this->nestedMappings)) {
if (isset($mapping['type']) && in_array($mapping['type'], ['nested', 'object']) && isset($mapping['properties']) && !empty($mapping['properties']) && array_key_exists($key, $this->nestedMappings)) {
foreach ($filteredFields as $key => $mapping) {
unset($filteredFields[$key]);
if (isset($mapping['type']) && in_array($mapping['type'], ['nested', 'object']) && isset($mapping['properties']) && !empty($mapping['properties']) && array_key_exists($key, $this->nestedMappings)) {
$path = '';
unset($filteredFields[$key]);
if (isset($mapping['property_path'])) {
$path = '';
$path = $mapping['property_path'];
if (isset($mapping['property_path'])) {
} else {
$path = $mapping['property_path'];
$path = $key;
} else {
}
$path = $key;
$filteredNestedFields = self::filterFields($mapping['properties'], self::extractFilterFields($this->nestedMappings[$key]));
}
$values = $this->propertyAccessor->getValue($entity, $path);
$filteredNestedFields = self::filterFields($mapping['properties'], self::extractFilterFields($this->nestedMappings[$key]));
if (!is_array($values)) {
$values = $this->propertyAccessor->getValue($entity, $path);
$values = [$values];
if (!is_array($values)) {
}
$values = [$values];
foreach ($values as $value) {
}
$nestedDoc = $this->transformNested($value, $filteredNestedFields)[0];
foreach ($values as $value) {
// Add our own stuff
$nestedDoc = $this->transformNested($value, $filteredNestedFields)[0];
$additionalValues = $this->extractAdditionalValues($value, $this->nestedMappings[$key]);
// Add our own stuff
foreach (array_keys($additionalValues) as $entity) {
$additionalValues = $this->extractAdditionalValues($value, $this->nestedMappings[$key]);
foreach ($additionalValues[$entity] as $field => $content) {
foreach (array_keys($additionalValues) as $entity) {
if ($nestedDoc->has($field)) {
foreach ($additionalValues[$entity] as $field => $content) {
$nestedDoc->remove($field);
if ($nestedDoc->has($field)) {
}
$nestedDoc->remove($field);
if (!empty($content)) {
}
$nestedDoc->set($field, $this->normalizeValue($content));
if (!empty($content)) {
} else {
$nestedDoc->set($field, $this->normalizeValue($content));
$nestedDoc->set($field, '');
} else {
 
$nestedDoc->set($field, '');
 
}
}
}
}
}
 
$filteredNestedDocs[$key][] = $nestedDoc;
}
}
$filteredNestedDocs[$key][] = $nestedDoc;
}
}
}
}
}
}
Loading