protected function LinkProviderManager::getValidatedLink in JSON:API Hypermedia 8
Gets a new, validated link.
Parameters
\Drupal\jsonapi\JsonApiResource\Link $link: The link to validate.
Return value
\Drupal\jsonapi\JsonApiResource\Link A new, validated link.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException Thrown if a link relation type plugin is improperly defined.
\Drupal\Component\Plugin\Exception\PluginException Thrown if a link relation type plugin could not be found.
1 call to LinkProviderManager::getValidatedLink()
- LinkProviderManager::getLinkCollection in src/
Plugin/ LinkProviderManager.php - Gets a LinkCollection of 3rd-party links for the given context object.
File
- src/
Plugin/ LinkProviderManager.php, line 161
Class
- LinkProviderManager
- Manages discovery and instantiation of resourceFieldEnhancer plugins.
Namespace
Drupal\jsonapi_hypermedia\PluginCode
protected function getValidatedLink(Link $link) {
$link_relation_type = $link
->getLinkRelationType();
$link_relation = $this->linkRelationTypeManager
->createInstance($link_relation_type);
assert($link_relation instanceof LinkRelationTypeInterface);
$link_relation_type_name = $link_relation
->isExtension() ? $link_relation
->getExtensionUri() : $link_relation
->getRegisteredName();
if (!$link_relation_type_name) {
throw new InvalidPluginDefinitionException($link_relation_type);
}
return new Link(CacheableMetadata::createFromObject($link), $link
->getUri(), $link_relation_type_name, $link
->getTargetAttributes());
}