function FileEntityNormalizer::normalize

Overrides ContentEntityNormalizer::normalize

Deprecated

in drupal:8.5.0 and is removed from drupal:9.0.0.

File

core/modules/hal/src/Normalizer/FileEntityNormalizer.php, line 67

Class

FileEntityNormalizer
Converts the Drupal entity object structure to a HAL array structure.

Namespace

Drupal\hal\Normalizer

Code

public function normalize($entity, $format = NULL, array $context = []) {
    $data = parent::normalize($entity, $format, $context);
    $this->addCacheableDependency($context, $this->halSettings);
    if ($this->halSettings
        ->get('bc_file_uri_as_url_normalizer')) {
        // Replace the file url with a full url for the file.
        $data['uri'][0]['value'] = $this->getEntityUri($entity);
        @trigger_error("Replacing the file uri with the URL is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the provided url property instead and disable hal.settings:bc_file_uri_as_url_normalizer. See https://www.drupal.org/node/2925783", E_USER_DEPRECATED);
    }
    return $data;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.