diff --git a/src/Normalizer/FieldItemNormalizer.php b/src/Normalizer/FieldItemNormalizer.php index 4f3b04c..6acea40 100644 --- a/src/Normalizer/FieldItemNormalizer.php +++ b/src/Normalizer/FieldItemNormalizer.php @@ -49,15 +49,20 @@ class FieldItemNormalizer extends NormalizerBase { // Convert tokens if there are any. // - // Note that because we lack entity data for the current field most tokens - // will not be honored. By specifying the token replacement should not clear - // tokens, the token value itself will be available for JSON consumers. + // Tokens are not cleared on failure to replace in case the token is useful. // - // @todo Remove token processing when support for denormalization is added. - $normalized['value'] = array_map(function($tag) { - return $this->metatagToken->replace($tag, [], [ - 'clear' => FALSE, - ]); + // @todo Move token processed version of content to a 'processed' key. + $entity = $field_item->getEntity(); + $normalized['value'] = array_map(function($tag) use ($entity) { + return $this->metatagToken->replace( + $tag, + [ + $entity->getEntityTypeId() => $entity, + ], + [ + 'clear' => FALSE, + ] + ); }, $normalized['value']); // Mock the field array similar to the other fields. @@ -67,6 +72,13 @@ class FieldItemNormalizer extends NormalizerBase { } /** + * {@inheritdoc} + */ + public function supportsDenormalization($data, $type, $format = NULL) { + return FALSE; + } + + /** * Extract the metatag overrides from the field item. * * @param \Drupal\Core\Field\FieldItemInterface $item