public static function WebformShareAccess::checkNodeAccess in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_share/src/Access/WebformShareAccess.php \Drupal\webform_share\Access\WebformShareAccess::checkNodeAccess()
Check whether the webform node can be shared.
Parameters
string $operation: Operation being performed.
string $entity_access: Entity access rule that needs to be checked.
\Drupal\node\NodeInterface $node: A node.
\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
1 string reference to 'WebformShareAccess::checkNodeAccess'
- webform_share.routing.yml in modules/
webform_share/ webform_share.routing.yml - modules/webform_share/webform_share.routing.yml
File
- modules/
webform_share/ src/ Access/ WebformShareAccess.php, line 50
Class
- WebformShareAccess
- Defines the custom access control handler for webform sharing.
Namespace
Drupal\webform_share\AccessCode
public static function checkNodeAccess($operation, $entity_access, NodeInterface $node, AccountInterface $account) {
/** @var \Drupal\webform\WebformEntityReferenceManagerInterface $entity_reference_manager */
$entity_reference_manager = \Drupal::service('webform.entity_reference_manager');
$webform = $entity_reference_manager
->getWebform($node);
// Check that the node has a valid webform reference.
if (!$webform) {
return AccessResult::forbidden()
->addCacheableDependency($node);
}
$share = $webform
->getSetting('share_node', TRUE);
if (!$share) {
return AccessResult::forbidden()
->addCacheTags([
'config:webform.settings',
])
->addCacheableDependency($node)
->addCacheableDependency($webform);
}
return WebformNodeAccess::checkAccess($operation, $entity_access, $node, NULL, $account);
}