protected function PrivateMessageThreadAccessControlHandler::checkAccess in Private Message 8
Same name and namespace in other branches
- 8.2 src/Entity/Access/PrivateMessageThreadAccessControlHandler.php \Drupal\private_message\Entity\Access\PrivateMessageThreadAccessControlHandler::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/
Entity/ Access/ PrivateMessageThreadAccessControlHandler.php, line 18
Class
- PrivateMessageThreadAccessControlHandler
- Access control handler for private message thread entities.
Namespace
Drupal\private_message\Entity\AccessCode
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
if ($account
->hasPermission('use private messaging system')) {
switch ($operation) {
case 'view':
if ($entity
->isMember($account
->id())) {
$messages = $entity
->filterUserDeletedMessages($account);
if (count($messages)) {
return AccessResult::allowed();
}
}
break;
case 'delete':
if ($entity
->isMember($account
->id())) {
return AccessResult::allowed();
}
break;
}
}
return AccessResult::neutral();
}