function NodeAccessTestAutoBubblingController::nodeAccessCacheability
Exposes the node label when a user has access to view a node.
Parameters
\Drupal\node\NodeInterface $node: A node entity.
Return value
array A render array.
1 string reference to 'NodeAccessTestAutoBubblingController::nodeAccessCacheability'
- node_access_test_auto_bubbling.routing.yml in core/
modules/ node/ tests/ node_access_test_auto_bubbling/ node_access_test_auto_bubbling.routing.yml - core/modules/node/tests/node_access_test_auto_bubbling/node_access_test_auto_bubbling.routing.yml
File
-
core/
modules/ node/ tests/ node_access_test_auto_bubbling/ src/ Controller/ NodeAccessTestAutoBubblingController.php, line 42
Class
- NodeAccessTestAutoBubblingController
- Returns a node ID listing.
Namespace
Drupal\node_access_test_auto_bubbling\ControllerCode
public function nodeAccessCacheability(NodeInterface $node) {
$build = [];
$cacheability = new CacheableMetadata();
$access = $node->access('view', return_as_object: TRUE);
$cacheability->addCacheableDependency($access);
if ($access->isAllowed()) {
$build[] = [
'#markup' => $node->label(),
];
$cacheability->addCacheableDependency($node);
}
$cacheability->applyTo($build);
return $build;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.