function social_post_comment_create_access in Open Social 8
Same name and namespace in other branches
- 8.9 modules/social_features/social_post/social_post.module \social_post_comment_create_access()
- 8.2 modules/social_features/social_post/social_post.module \social_post_comment_create_access()
- 8.3 modules/social_features/social_post/social_post.module \social_post_comment_create_access()
- 8.4 modules/social_features/social_post/social_post.module \social_post_comment_create_access()
- 8.5 modules/social_features/social_post/social_post.module \social_post_comment_create_access()
- 8.6 modules/social_features/social_post/social_post.module \social_post_comment_create_access()
- 8.7 modules/social_features/social_post/social_post.module \social_post_comment_create_access()
- 8.8 modules/social_features/social_post/social_post.module \social_post_comment_create_access()
- 10.3.x modules/social_features/social_post/social_post.module \social_post_comment_create_access()
- 10.0.x modules/social_features/social_post/social_post.module \social_post_comment_create_access()
- 10.1.x modules/social_features/social_post/social_post.module \social_post_comment_create_access()
- 10.2.x modules/social_features/social_post/social_post.module \social_post_comment_create_access()
Implements hook_ENTITY_TYPE_create_access().
File
- modules/
social_features/ social_post/ social_post.module, line 203 - The Social post module.
Code
function social_post_comment_create_access(AccountInterface $account, array $context, $entity_bundle) {
if ($entity_bundle === 'post_comment') {
$group = \Drupal::routeMatch()
->getParameter('group');
if (is_numeric($group) && !$group instanceof GroupInterface) {
$group = Group::load($group);
}
if ($group) {
if ($group
->hasPermission('add post entities in group', $account)) {
return AccessResult::allowed()
->cachePerUser();
}
else {
return AccessResult::forbidden()
->cachePerUser();
}
}
}
return AccessResult::neutral();
}