public function ContentEntityNormalizer::normalize in Tome 8
Overrides ContentEntityNormalizer::normalize
2 calls to ContentEntityNormalizer::normalize()
- PathAliasNormalizer::normalize in modules/
tome_sync/ src/ Normalizer/ PathAliasNormalizer.php - Normalizes an object into a set of arrays/scalars.
- UserEntityNormalizer::normalize in modules/
tome_sync/ src/ Normalizer/ UserEntityNormalizer.php - Normalizes an object into a set of arrays/scalars.
2 methods override ContentEntityNormalizer::normalize()
- PathAliasNormalizer::normalize in modules/
tome_sync/ src/ Normalizer/ PathAliasNormalizer.php - Normalizes an object into a set of arrays/scalars.
- UserEntityNormalizer::normalize in modules/
tome_sync/ src/ Normalizer/ UserEntityNormalizer.php - Normalizes an object into a set of arrays/scalars.
File
- modules/
tome_sync/ src/ Normalizer/ ContentEntityNormalizer.php, line 41
Class
- ContentEntityNormalizer
- Normalizes/denormalizes Drupal content entities into an array structure.
Namespace
Drupal\tome_sync\NormalizerCode
public function normalize($entity, $format = NULL, array $context = []) {
$values = parent::normalize($entity, $format, $context);
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity_type = $entity
->getEntityType();
$id_key = $entity_type
->getKey('id');
// User IDs are important to retain to ensure that User 1 is consistent
// across rebuilds. We unset the ID key otherwise to make merging easier.
// Imagine fighting over the next Node ID with an upstream repo! Yuck.
if ($entity_type
->id() !== 'user' && $id_key && isset($values[$id_key])) {
unset($values[$id_key]);
}
$id_key = $entity_type
->getKey('revision');
if ($id_key && isset($values[$id_key])) {
unset($values[$id_key]);
}
foreach ($this->fieldDenyList as $field_name) {
if (isset($values[$field_name])) {
unset($values[$field_name]);
}
}
foreach ($this->entityTypeDenyList as $key) {
$field_name = $entity
->getEntityType()
->get($key);
if ($field_name && isset($values[$field_name])) {
unset($values[$field_name]);
}
}
return $values;
}