You are here

protected function CommentGroupContentFormatter::getPermissionInGroups in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()
  2. 8 modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()
  3. 8.2 modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()
  4. 8.3 modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()
  5. 8.4 modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()
  6. 8.5 modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()
  7. 8.6 modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()
  8. 8.7 modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()
  9. 8.8 modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()
  10. 10.0.x modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()
  11. 10.1.x modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()
  12. 10.2.x modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php \Drupal\group_core_comments\Plugin\Field\FieldFormatter\CommentGroupContentFormatter::getPermissionInGroups()

Checks if account was granted permission in group.

1 call to CommentGroupContentFormatter::getPermissionInGroups()
CommentGroupContentFormatter::viewElements in modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php
Builds a renderable array for a field value.

File

modules/custom/group_core_comments/src/Plugin/Field/FieldFormatter/CommentGroupContentFormatter.php, line 272

Class

CommentGroupContentFormatter
Plugin implementation of the 'comment_group_content' formatter.

Namespace

Drupal\group_core_comments\Plugin\Field\FieldFormatter

Code

protected function getPermissionInGroups($perm, AccountInterface $account, $group_contents, &$output) {
  foreach ($group_contents as $group_content) {
    $group = $group_content
      ->getGroup();

    // Add cacheable dependency.
    $membership = $group
      ->getMember($account);
    $this->renderer
      ->addCacheableDependency($output, $membership);
    if ($group
      ->hasPermission($perm, $account)) {
      return AccessResult::allowed()
        ->cachePerUser();
    }
  }

  // Fallback.
  return AccessResult::forbidden()
    ->cachePerUser();
}