Skip to content

Commit

Permalink
[Data Object Editor] Field-Collections with block and localized field…
Browse files Browse the repository at this point in the history
…s not working (#609)

* localized fields adapter not returning values

* Add context to getFieldDefinition().

* Null check.

* Remove roave/security-advisories

---------

Co-authored-by: lukmzig <lukas.mzigot@pimcore.com>
  • Loading branch information
martineiber and lukmzig authored Dec 3, 2024
1 parent 6f557dd commit 4d2cb3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
},
"require-dev": {
"pimcore/admin-ui-classic-bundle": "^v1.3",
"roave/security-advisories": "dev-latest",
"codeception/codeception": "^5.0.10",
"codeception/phpunit-wrapper": "^9",
"codeception/module-asserts": "^2",
Expand Down
12 changes: 10 additions & 2 deletions src/DataObject/Data/Adapter/LocalizedFieldsAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Pimcore\Bundle\StudioBackendBundle\DataObject\Util\Trait\ValidateFieldTypeTrait;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\DatabaseException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidArgumentException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\ElementPermissions;
use Pimcore\Model\DataObject\ClassDefinition\Data;
Expand Down Expand Up @@ -111,6 +112,9 @@ public function normalize(

$value->loadLazyData();
$originalValue = $fieldDefinition->normalize($value);
if ($originalValue === null) {
return null;
}
$languages = array_keys($originalValue);
$attributes = array_keys(reset($originalValue));
$result = [];
Expand All @@ -126,8 +130,12 @@ public function normalize(
)
);
}
$fieldDefinition = $value->getFieldDefinition($attribute);
$localizedValue = $this->dataService->getNormalizedValue($localizedValue, $fieldDefinition);
$fieldDefinition = $value->getFieldDefinition($attribute, $value->getContext());
if ($fieldDefinition === null) {
throw new NotFoundException(type: 'Field Definition', id: $attribute);
}

$localizedValue = $this->dataService->getNormalizedValue($localizedValue, $fieldDefinition);
$result[$attribute][$language] = $localizedValue;
}
}
Expand Down

0 comments on commit 4d2cb3a

Please sign in to comment.