protected function EntityQueueAccessControlHandler::checkAccess in Entityqueue 8
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/
EntityQueueAccessControlHandler.php, line 20
Class
- EntityQueueAccessControlHandler
- Defines the access control handler for the entity_queue entity type.
Namespace
Drupal\entityqueueCode
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\entityqueue\EntitySubqueueInterface $entity */
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'access content');
break;
case 'update':
case 'enable':
case 'disable':
return AccessResult::allowedIfHasPermissions($account, [
"update {$entity->id()} entityqueue",
'manipulate all entityqueues',
'administer entityqueue',
], 'OR');
break;
case 'delete':
return AccessResult::allowedIfHasPermissions($account, [
"delete {$entity->id()} entityqueue",
'manipulate all entityqueues',
'administer entityqueue',
], 'OR');
break;
default:
// No opinion.
return AccessResult::neutral();
}
}