You are here

protected static function ResourceResponseTestTrait::getResourceLink in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php \Drupal\Tests\jsonapi\Functional\ResourceResponseTestTrait::getResourceLink()
  2. 9 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.

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();
}