function HttpExceptionNormalizer::normalize

Same name in other branches
  1. 9 core/modules/jsonapi/src/Normalizer/HttpExceptionNormalizer.php \Drupal\jsonapi\Normalizer\HttpExceptionNormalizer::normalize()
  2. 8.9.x core/modules/jsonapi/src/Normalizer/HttpExceptionNormalizer.php \Drupal\jsonapi\Normalizer\HttpExceptionNormalizer::normalize()
  3. 11.x core/modules/jsonapi/src/Normalizer/HttpExceptionNormalizer.php \Drupal\jsonapi\Normalizer\HttpExceptionNormalizer::normalize()

File

core/modules/jsonapi/src/Normalizer/HttpExceptionNormalizer.php, line 44

Class

HttpExceptionNormalizer
Normalizes an HttpException in compliance with the JSON:API specification.

Namespace

Drupal\jsonapi\Normalizer

Code

public function normalize($object, $format = NULL, array $context = []) : array|string|int|float|bool|\ArrayObject|null {
    $cacheability = new CacheableMetadata();
    $cacheability->addCacheableDependency($object);
    $cacheability->addCacheTags([
        'config:system.logging',
    ]);
    if (\Drupal::config('system.logging')->get('error_level') === ERROR_REPORTING_DISPLAY_VERBOSE) {
        $cacheability->setCacheMaxAge(0);
    }
    return new HttpExceptionNormalizerValue($cacheability, static::rasterizeValueRecursive($this->buildErrorObjects($object)));
}

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