public function CommentItemNormalizer::normalize in Replication 8
Same name and namespace in other branches
- 8.2 src/Normalizer/CommentItemNormalizer.php \Drupal\replication\Normalizer\CommentItemNormalizer::normalize()
Overrides ComplexDataNormalizer::normalize
File
- src/
Normalizer/ CommentItemNormalizer.php, line 24
Class
Namespace
Drupal\replication\NormalizerCode
public function normalize($field, $format = NULL, array $context = []) {
$value = $field
->getValue();
$field_info = [];
$reference_fields = [
'cid',
'last_comment_uid',
];
foreach ($value as $key => $item) {
if (in_array($key, $reference_fields) && is_numeric($item)) {
$field_info[$key] = NULL;
}
else {
$field_info[$key] = $item;
}
}
return $field_info;
}