decorateExpectedResponseForIncludedFields example

$expected_related_responses = $this->getExpectedRelatedResponses($included_paths$request_options$entity);
      if (empty($related_responses)) {
        return $expected_related_responses;
      }
      foreach ($included_paths as $included_path) {
        $both_responses = [$related_responses[$included_path]$expected_related_responses[$included_path]];
        $related_responses[$included_path] = static::toCollectionResourceResponse($both_responses$self_link, TRUE);
      }
      return $related_responses;
    }[]);

    return static::decorateExpectedResponseForIncludedFields($collection_response$related_responses);
  }

  /** * Tests GET of the related resource of an individual resource. * * Expected responses are built by making requests to 'relationship' routes. * Using the fetched resource identifiers, if any, all targeted resources are * fetched individually. These individual responses are then 'merged' into a * single expected ResourceResponse. This is repeated for every relationship * field of the resource type under test. */
  

          'self' => [
            'href' => $expected_base_url->toString() . '/relationships/field_jsonapi_test_entity_ref' . $version_query_string,
          ],
        ],
      ];
    }

    $basic_cacheability = (new CacheableMetadata())
      ->addCacheTags($this->getExpectedCacheTags())
      ->addCacheContexts($this->getExpectedCacheContexts());
    return static::decorateExpectedResponseForIncludedFields(new CacheableResourceResponse($individual_document)$resource_data['responses'])
      ->addCacheableDependency($basic_cacheability);
  }

  /** * Maps an array of PSR responses to JSON:API ResourceResponses. * * @param \Psr\Http\Message\ResponseInterface[] $responses * The PSR responses to be mapped. * * @return \Drupal\jsonapi\ResourceResponse[] * The ResourceResponses. */
Home | Imprint | This part of the site doesn't use cookies.