protected static function ResourceResponseTestTrait::getResourceLink in JSON:API 8
Same name and namespace in other branches
- 8.2 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 tests/
src/ Functional/ ResourceResponseTestTrait.php - Creates a related resource link for a given resource identifier and field.
- ResourceResponseTestTrait::getRelationshipLink in tests/
src/ Functional/ ResourceResponseTestTrait.php - Creates a relationship link for a given resource identifier and field.
- ResourceTestBase::doTestSparseFieldSets in tests/
src/ Functional/ ResourceTestBase.php - Tests sparse field sets.
File
- tests/
src/ Functional/ ResourceResponseTestTrait.php, line 351
Class
- ResourceResponseTestTrait
- Utility methods for handling resource responses.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected static function getResourceLink(array $resource_identifier) {
assert(static::isResourceIdentifier($resource_identifier));
$resource_type = $resource_identifier['type'];
$resource_id = $resource_identifier['id'];
$entity_type_id = explode('--', $resource_type)[0];
$url = Url::fromRoute(sprintf('jsonapi.%s.individual', $resource_type), [
$entity_type_id => $resource_id,
]);
return $url
->setAbsolute()
->toString();
}