diff --git a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php index 9cc570c..ea21dac 100644 --- a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php +++ b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php @@ -46,6 +46,13 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ + public function isEmpty() { + return ($this->alias === NULL || $this->alias === '') && ($this->pid === NULL || $this->pid === ''); + } + + /** + * {@inheritdoc} + */ public function preSave() { $this->alias = trim($this->alias); } diff --git a/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php b/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php index d3abef6..ad3f02e 100644 --- a/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php +++ b/core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php @@ -22,6 +22,7 @@ public function normalize($entity, $format = NULL, array $context = []) { $attributes = []; foreach ($entity as $name => $field_items) { + $field_items->filterEmptyItems(); if ($field_items->access('view', $context['account'])) { $attributes[$name] = $this->serializer->normalize($field_items, $format, $context); }