protected function LinkProviderManager::bubbleAccessCacheability in JSON:API Hypermedia 8
Bubbles access-related cacheability of the link.
@todo: removes this once https://www.drupal.org/project/drupal/issues/3055889 lands.
Parameters
\Drupal\Core\Cache\CacheableMetadata|null $cacheability: The access related cacheability to be captured or NULL if there is none.
1 call to LinkProviderManager::bubbleAccessCacheability()
- 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 180
Class
- LinkProviderManager
- Manages discovery and instantiation of resourceFieldEnhancer plugins.
Namespace
Drupal\jsonapi_hypermedia\PluginCode
protected function bubbleAccessCacheability($cacheability) {
assert(is_null($cacheability) || $cacheability instanceof CacheableMetadata);
if (is_null($cacheability)) {
return;
}
$request = \Drupal::requestStack()
->getCurrentRequest();
$renderer = \Drupal::service('renderer');
if ($request
->isMethodCacheable() && $renderer
->hasRenderContext()) {
$build = [];
$cacheability
->applyTo($build);
$renderer
->render($build);
}
}