diff --git a/src/contracts/Repository/Values/ValueObject.php b/src/contracts/Repository/Values/ValueObject.php index 3aa5b81e76..0ab3d6e7fe 100644 --- a/src/contracts/Repository/Values/ValueObject.php +++ b/src/contracts/Repository/Values/ValueObject.php @@ -8,6 +8,7 @@ use Ibexa\Contracts\Core\Repository\Exceptions\PropertyNotFoundException; use Ibexa\Contracts\Core\Repository\Exceptions\PropertyReadOnlyException; +use Symfony\Component\Serializer\Annotation\Ignore as SerializerIgnore; /** * The base class for all value objects and structs. @@ -46,6 +47,8 @@ public function __construct(array $properties = []) * @param array $dynamicProperties Additional dynamic properties exposed on the object * * @return array + * + * @SerializerIgnore() */ protected function getProperties($dynamicProperties = []) { @@ -201,6 +204,8 @@ final public function attributes() * @param string $property * * @return bool + * + * @SerializerIgnore() */ final public function hasAttribute($property) { diff --git a/tests/integration/Core/Repository/SerializationTest.php b/tests/integration/Core/Repository/SerializationTest.php new file mode 100644 index 0000000000..2e65ca6f74 --- /dev/null +++ b/tests/integration/Core/Repository/SerializationTest.php @@ -0,0 +1,55 @@ +getContainer()->get(SerializerInterface::class); + self::assertInstanceOf(SerializerInterface::class, $serializer); + $contentService = self::getContentService(); + + $user = $contentService->loadContent(14); + $field = $user->getField('user_account'); + self::assertNotNull($field, 'Field "name" for admin user should not be null'); + + $result = $serializer->serialize($field, 'json', [JsonEncode::OPTIONS => JSON_PRETTY_PRINT]); + $passwordHash = '$2y$10$FDn9NPwzhq85cLLxfD5Wu.L3SL3Z\/LNCvhkltJUV0wcJj7ciJg2oy'; + self::assertSame( + <<