You are here

protected static function ResourceResponseTestTrait::getResourceLink in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php \Drupal\Tests\jsonapi\Functional\ResourceResponseTestTrait::getResourceLink()

Creates an individual resource link for a given resource identifier.

Parameters

array $resource_identifier: A resource identifier for which to create a link.

Return value

string The resource link.

3 calls to ResourceResponseTestTrait::getResourceLink()
ResourceResponseTestTrait::getRelatedLink in core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php
Creates a related resource link for a given resource identifier and field.
ResourceResponseTestTrait::getRelationshipLink in core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php
Creates a relationship link for a given resource identifier and field.
ResourceTestBase::doTestSparseFieldSets in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Tests sparse field sets.

File

core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php, line 380

Class

ResourceResponseTestTrait
Utility methods for handling resource responses.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected static function getResourceLink(array $resource_identifier) {
  assert(static::isResourceIdentifier($resource_identifier));
  $resource_type = $resource_identifier['type'];
  $resource_id = $resource_identifier['id'];
  $url = Url::fromRoute(sprintf('jsonapi.%s.individual', $resource_type), [
    'entity' => $resource_id,
  ]);
  return $url
    ->setAbsolute()
    ->toString();
}