diff --git a/core/lib/Drupal/Core/TypedData/DataDefinition.php b/core/lib/Drupal/Core/TypedData/DataDefinition.php index 38c2846cac..332659feaa 100644 --- a/core/lib/Drupal/Core/TypedData/DataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/DataDefinition.php @@ -369,8 +369,7 @@ public function isInternal() { * @param bool $internal * Whether the data value should be internal. * - * @return static - * The object itself for chaining. + * @return $this */ public function setInternal($internal) { $this->definition['internal'] = $internal; diff --git a/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php b/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php index b8a5dafd12..178db1cc6e 100644 --- a/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php +++ b/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php @@ -6,7 +6,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Field\FieldItemListInterface; use Drupal\hal\LinkManager\LinkManagerInterface; use Drupal\serialization\Normalizer\ComplexDataPropertiesNormalizerTrait; use Drupal\serialization\Normalizer\FieldableEntityNormalizerTrait; @@ -79,9 +78,7 @@ public function normalize($entity, $format = NULL, array $context = []) { $field_items = static::getNonInternalAccessibleProperties($entity->getTypedData(), $context); // If the fields to use were specified, only output those field values. if (isset($context['included_fields'])) { - $field_items = array_filter($field_items, function (FieldItemListInterface $field_item) use ($context) { - return in_array($field_item->getName(), $context['included_fields']); - }); + $field_items = array_intersect_key($field_items, array_flip($context['included_fields'])); } foreach ($field_items as $field) { $normalized_property = $this->serializer->normalize($field, $format, $context);