public static function AccessRestrictedLink::createLink in JSON:API Hypermedia 8
Creates an AccessRestrictedLink.
Note that in some cases, it is preferable to use static::createInaccessibleLink() instead of this method. Using that method instead of this one does not require as many arguments and therefore does not require the caller to construct a phony URL.
Parameters
\Drupal\Core\Access\AccessResultInterface $access_result: The link access result. This is typically an access result related to whether the current user is able to follow the link or not. Don't forget to add cacheability information to the result as necessary.
\Drupal\Core\Cache\CacheableDependencyInterface $link_cacheability: The cacheability of the generated link. This is typically cacheability related to the URL, the link relation types, or the link's target attributes. For example, a link might use the `hreflang` target attribute to indicate the available translations of a target resource and so the link's cacheability might have a cache context related to the current language as well as a cache tag that would be invalidated when a new translation is added.
\Drupal\Core\Url $url: The link URL.
string $link_relation_type: The link's relation type.
array $target_attributes: (optional) The link's target attributes.
\Drupal\Core\Url $context: (optional) The link's context. This will override the default link context via an `anchor` link param. The default context is derived from a link's location in the response document.
Return value
static A new link object.
See also
\Drupal\jsonapi_hypermedia\AccessRestrictedLink::createInaccessibleLink()
4 calls to AccessRestrictedLink::createLink()
- AuthenticationLinkProvider::getLink in examples/
Plugin/ jsonapi_hypermedia/ LinkProvider/ AuthenticationLinkProvider.php - Adds, alters or removes hyperlinks from a link collection.
- EntityPublishedInterfaceLinkProvider::getLink in examples/
Plugin/ jsonapi_hypermedia/ LinkProvider/ EntityPublishedInterfaceLinkProvider.php - Adds, alters or removes hyperlinks from a link collection.
- MutableResourceTypeLinkProvider::getLink in examples/
Plugin/ jsonapi_hypermedia/ LinkProvider/ MutableResourceTypeLinkProvider.php - Adds, alters or removes hyperlinks from a link collection.
- TestLinkProvider::getLink in tests/
modules/ jsonapi_hypermedia_test_link_providers/ src/ Plugin/ jsonapi_hypermedia/ LinkProvider/ TestLinkProvider.php - Adds, alters or removes hyperlinks from a link collection.
File
- src/
AccessRestrictedLink.php, line 106
Class
- AccessRestrictedLink
- Decorates a JSON:API link to consider link accessibility.
Namespace
Drupal\jsonapi_hypermediaCode
public static function createLink(AccessResultInterface $access_result, CacheableDependencyInterface $link_cacheability, Url $url, $link_relation_type, array $target_attributes = [], Url $context = NULL) {
return new static($access_result, $link_cacheability, $url, $link_relation_type, $target_attributes, $context);
}