function ContentEntityNormalizer::normalize
Same name in other branches
- 9 core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php \Drupal\serialization\Normalizer\ContentEntityNormalizer::normalize()
- 9 core/modules/hal/src/Normalizer/ContentEntityNormalizer.php \Drupal\hal\Normalizer\ContentEntityNormalizer::normalize()
- 8.9.x core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php \Drupal\serialization\Normalizer\ContentEntityNormalizer::normalize()
- 8.9.x core/modules/hal/src/Normalizer/ContentEntityNormalizer.php \Drupal\hal\Normalizer\ContentEntityNormalizer::normalize()
- 11.x core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php \Drupal\serialization\Normalizer\ContentEntityNormalizer::normalize()
Overrides ComplexDataNormalizer::normalize
File
-
core/
modules/ serialization/ src/ Normalizer/ ContentEntityNormalizer.php, line 16
Class
- ContentEntityNormalizer
- Normalizes/denormalizes Drupal content entities into an array structure.
Namespace
Drupal\serialization\NormalizerCode
public function normalize($entity, $format = NULL, array $context = []) : array|string|int|float|bool|\ArrayObject|null {
$context += [
'account' => NULL,
];
$attributes = [];
/** @var \Drupal\Core\Entity\Entity $entity */
foreach (TypedDataInternalPropertiesHelper::getNonInternalProperties($entity->getTypedData()) as $name => $field_items) {
if ($field_items->access('view', $context['account'])) {
$attributes[$name] = $this->serializer
->normalize($field_items, $format, $context);
}
}
return $attributes;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.