public function ContentEntityNormalizer::normalize in Drupal 9
Same name in this branch
- 9 core/modules/hal/src/Normalizer/ContentEntityNormalizer.php \Drupal\hal\Normalizer\ContentEntityNormalizer::normalize()
- 9 core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php \Drupal\serialization\Normalizer\ContentEntityNormalizer::normalize()
Same name and namespace in other branches
- 8 core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php \Drupal\serialization\Normalizer\ContentEntityNormalizer::normalize()
Overrides ComplexDataNormalizer::normalize
File
- core/
modules/ serialization/ src/ Normalizer/ ContentEntityNormalizer.php, line 21
Class
- ContentEntityNormalizer
- Normalizes/denormalizes Drupal content entities into an array structure.
Namespace
Drupal\serialization\NormalizerCode
public function normalize($entity, $format = NULL, array $context = []) {
$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;
}