core/modules/hal/src/Normalizer/ContentEntityNormalizer.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php b/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php index 4a9f7c4..9047828 100644 --- a/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php +++ b/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php @@ -8,6 +8,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\TypedData\TypedDataInternalPropertiesHelper; use Drupal\hal\LinkManager\LinkManagerInterface; +use Drupal\rest\EventSubscriber\ResourceResponseSubscriber; use Drupal\serialization\Normalizer\FieldableEntityNormalizerTrait; use Symfony\Component\Serializer\Exception\UnexpectedValueException; @@ -179,17 +180,22 @@ public function denormalize($data, $class, $format = NULL, array $context = []) * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity. + * @param array $context + * Normalization/serialization context. + * * @return string * The entity URI. */ - protected function getEntityUri(EntityInterface $entity) { + protected function getEntityUri(EntityInterface $entity, array $context = []) { // Some entity types don't provide a canonical link template, at least call // out to ->url(). if ($entity->isNew() || !$entity->hasLinkTemplate('canonical')) { return $entity->url('canonical', []); } $url = $entity->urlInfo('canonical', ['absolute' => TRUE]); - return $url->setRouteParameter('_format', 'hal_json')->toString(); + $generated_url = $url->setRouteParameter('_format', 'hal_json')->toString(TRUE); + $this->addCacheableDependency($context, $generated_url); + return $generated_url->getGeneratedUrl(); } /**