function social_comment_comment_access in Open Social 8
Same name and namespace in other branches
- 8.9 modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
- 8.2 modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
- 8.3 modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
- 8.4 modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
- 8.5 modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
- 8.6 modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
- 8.7 modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
- 8.8 modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
- 10.3.x modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
- 10.0.x modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
- 10.1.x modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
- 10.2.x modules/social_features/social_comment/social_comment.module \social_comment_comment_access()
Implements hook_ENTITY_TYPE_access().
Allow users to delete their own comments.
File
- modules/
social_features/ social_comment/ social_comment.module, line 164 - The Social comment module.
Code
function social_comment_comment_access(EntityInterface $entity, $operation, AccountInterface $account) {
if ($operation == 'delete') {
if ($account
->hasPermission('administer comments', $account)) {
return AccessResult::allowed()
->cachePerPermissions();
}
else {
return AccessResult::allowedIf($account
->hasPermission('delete own comments', $account) && $account
->id() == $entity
->getOwnerId())
->cachePerPermissions()
->cachePerUser()
->addCacheableDependency($entity);
}
}
}