protected function RelationAccessControlHandler::checkAccess in Relation 8
Same name and namespace in other branches
- 8.2 src/RelationAccessControlHandler.php \Drupal\relation\RelationAccessControlHandler::checkAccess()
Performs access checks.
This method is supposed to be overwritten by extending classes that do their own custom access checking.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for which to check access.
string $operation: The entity operation. Usually one of 'view', 'view label', 'update' or 'delete'.
\Drupal\Core\Session\AccountInterface $account: The user for which to check access.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
Overrides EntityAccessControlHandler::checkAccess
File
- src/
RelationAccessControlHandler.php, line 21 - Contains \Drupal\relation\RelationAccessControlHandler.
Class
- RelationAccessControlHandler
- Defines the access controller for Relations.
Namespace
Drupal\relationCode
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
if ($parent = parent::checkAccess($entity, $operation, $account)) {
return $parent;
}
if ($operation === 'create' && $account
->hasPermission('create relations')) {
return TRUE;
}
elseif ($operation === 'view' && $account
->hasPermission('access relations')) {
return TRUE;
}
elseif ($operation === 'update' && $account
->hasPermission('edit relations')) {
return TRUE;
}
elseif ($operation === 'delete' && $account
->hasPermission('delete relations')) {
return TRUE;
}
}