function ResourceObjectNormalizer::buildEmptyNormalization

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

Builds the empty normalization structure for cache misses.

Parameters

\Drupal\jsonapi\JsonApiResource\ResourceObject $object: The resource object being normalized.

Return value

array The normalization structure as defined in ::getNormalization().

See also

::getNormalization()

1 call to ResourceObjectNormalizer::buildEmptyNormalization()
ResourceObjectNormalizer::getNormalization in core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php
Normalizes an entity using the given fieldset.

File

core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php, line 145

Class

ResourceObjectNormalizer
Converts the JSON:API module ResourceObject into a JSON:API array structure.

Namespace

Drupal\jsonapi\Normalizer

Code

protected static function buildEmptyNormalization(ResourceObject $object) {
    return [
        ResourceObjectNormalizationCacher::RESOURCE_CACHE_SUBSET_BASE => [
            'type' => CacheableNormalization::permanent($object->getResourceType()
                ->getTypeName()),
            'id' => CacheableNormalization::permanent($object->getId()),
        ],
        ResourceObjectNormalizationCacher::RESOURCE_CACHE_SUBSET_FIELDS => [],
    ];
}

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