class NodeGrantAccessCheck in Nodeaccess 8.2
Same name and namespace in other branches
- 8 src/AccessChecks/NodeGrantAccessCheck.php \Drupal\nodeaccess\AccessChecks\NodeGrantAccessCheck
A custom access check for grants form.
Hierarchy
- class \Drupal\nodeaccess\AccessChecks\NodeGrantAccessCheck implements AccessInterface
Expanded class hierarchy of NodeGrantAccessCheck
1 string reference to 'NodeGrantAccessCheck'
File
- src/
AccessChecks/ NodeGrantAccessCheck.php, line 13
Namespace
Drupal\nodeaccess\AccessChecksView source
class NodeGrantAccessCheck implements AccessInterface {
/**
* A custom access check.
*/
public function access($node, AccountInterface $account) {
if (!$node) {
return AccessResult::forbidden();
}
$nid = $node;
$node = Node::load($nid);
$config = \Drupal::configFactory()
->get('nodeaccess.settings');
$allowed_types = $config
->get('allowed_types');
if ($node && isset($allowed_types[$node
->getType()]) && !empty($allowed_types[$node
->getType()]) && ($account
->hasPermission('grant node permissions') || $account
->hasPermission('administer nodeaccess'))) {
return AccessResult::Allowed();
}
return AccessResult::forbidden();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
NodeGrantAccessCheck:: |
public | function | A custom access check. |