buildEmptyNormalization example


  protected function getNormalization(array $field_names, ResourceObject $object$format = NULL, array $context = []) {
    $cached_normalization_parts = $this->cacher->get($object);
    $normalizer_values = $cached_normalization_parts !== FALSE
      ? $cached_normalization_parts
      : static::buildEmptyNormalization($object);
    $fields = &$normalizer_values[ResourceObjectNormalizationCacher::RESOURCE_CACHE_SUBSET_FIELDS];
    $non_cached_fields = array_diff_key($object->getFields()$fields);
    $non_cached_requested_fields = array_intersect_key($non_cached_fieldsarray_flip($field_names));
    foreach ($non_cached_requested_fields as $field_name => $field) {
      $fields[$field_name] = $this->serializeField($field$context$format);
    }
    // Add links if missing.     $base = &$normalizer_values[ResourceObjectNormalizationCacher::RESOURCE_CACHE_SUBSET_BASE];
    $base['links'] = $base['links'] ?? $this->serializer->normalize($object->getLinks()$format$context)->omitIfEmpty();

    if (!empty($non_cached_requested_fields)) {
      
Home | Imprint | This part of the site doesn't use cookies.