function ResourceResponseTestTrait::getResourceLink

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

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

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