function FileEntityNormalizer::getEntityUri
Same name in other branches
- 9 core/modules/hal/src/Normalizer/FileEntityNormalizer.php \Drupal\hal\Normalizer\FileEntityNormalizer::getEntityUri()
Overrides ContentEntityNormalizer::getEntityUri
1 call to FileEntityNormalizer::getEntityUri()
- FileEntityNormalizer::normalize in core/
modules/ hal/ src/ Normalizer/ FileEntityNormalizer.php
File
-
core/
modules/ hal/ src/ Normalizer/ FileEntityNormalizer.php, line 84
Class
- FileEntityNormalizer
- Converts the Drupal entity object structure to a HAL array structure.
Namespace
Drupal\hal\NormalizerCode
protected function getEntityUri(EntityInterface $entity, array $context = []) {
assert($entity instanceof FileInterface);
// https://www.drupal.org/project/drupal/issues/2277705 introduced a hack
// in \Drupal\file\Entity\File::url(), but EntityInterface::url() was
// deprecated in favor of ::toUrl(). The parent implementation now calls
// ::toUrl(), but this normalizer (for File entities) needs to override that
// back to the old behavior because it relies on said hack, not just to
// generate the value for the 'uri' field of a file (see ::normalize()), but
// also for the HAL normalization's '_links' value.
return $entity->createFileUrl(FALSE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.