diff --git a/core/modules/serialization/serialization.services.yml b/core/modules/serialization/serialization.services.yml index 389ac05..f32fac0 100644 --- a/core/modules/serialization/serialization.services.yml +++ b/core/modules/serialization/serialization.services.yml @@ -7,6 +7,11 @@ services: tags: - { name: normalizer } arguments: ['@entity.manager'] + serializer.normalizer.content_entity: + class: Drupal\serialization\Normalizer\ContentEntityNormalizer + tags: + - { name: normalizer } + arguments: ['@entity.manager'] serializer.normalizer.entity: class: Drupal\serialization\Normalizer\EntityNormalizer tags: diff --git a/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php b/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php new file mode 100644 index 0000000..e656dec --- /dev/null +++ b/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php @@ -0,0 +1,35 @@ + $field) { + if ($field->access('view')) { + $attributes[$name] = $this->serializer->normalize($field, $format); + } + } + return $attributes; + } + +} diff --git a/core/modules/serialization/src/Tests/EntitySerializationTest.php b/core/modules/serialization/src/Tests/EntitySerializationTest.php index 0f3bdb5..d45c2a6 100644 --- a/core/modules/serialization/src/Tests/EntitySerializationTest.php +++ b/core/modules/serialization/src/Tests/EntitySerializationTest.php @@ -117,7 +117,8 @@ public function testNormalize() { ]); $account->save(); $normalized = $this->serializer->normalize($account); - $this->assertEqual($normalized['pass'], [[]]); + $this->assertTrue(empty($normalized['pass'])); + $this->assertTrue(empty($normalized['mail'])); } /**