protected function OpignoAnswerAccessControlHandler::checkAccess in Opigno module 3.x
Same name and namespace in other branches
- 8 src/OpignoAnswerAccessControlHandler.php \Drupal\opigno_module\OpignoAnswerAccessControlHandler::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/
OpignoAnswerAccessControlHandler.php, line 20
Class
- OpignoAnswerAccessControlHandler
- Access controller for the Answer entity.
Namespace
Drupal\opigno_moduleCode
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\opigno_module\Entity\OpignoAnswerInterface $entity */
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'view published answer entities');
case 'update':
return AccessResult::allowedIfHasPermission($account, 'edit answer entities');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete answer entities');
}
// Unknown operation, no opinion.
return AccessResult::neutral();
}