You are here

protected function ContentReportActivityContext::getRolesWithPermission in Open Social 8.9

Same name and namespace in other branches
  1. 8.5 modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext::getRolesWithPermission()
  2. 8.6 modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext::getRolesWithPermission()
  3. 8.7 modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext::getRolesWithPermission()
  4. 8.8 modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext::getRolesWithPermission()
  5. 10.3.x modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext::getRolesWithPermission()
  6. 10.0.x modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext::getRolesWithPermission()
  7. 10.1.x modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext::getRolesWithPermission()
  8. 10.2.x modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php \Drupal\social_content_report\Plugin\ActivityContext\ContentReportActivityContext::getRolesWithPermission()

Returns the role with the required permission.

Return value

array A list of Role IDs.

File

modules/social_features/social_content_report/src/Plugin/ActivityContext/ContentReportActivityContext.php, line 47

Class

ContentReportActivityContext
Provides a 'ContentReportActivityContext' activity context.

Namespace

Drupal\social_content_report\Plugin\ActivityContext

Code

protected function getRolesWithPermission() {
  $roles_with_perm = [];

  /* @var \Drupal\user\RoleInterface[] $roles */
  $roles = $this->entityTypeManager
    ->getStorage('user_role')
    ->loadMultiple();

  // Check for each role which one has permission to "view inappropriate
  // reports".
  foreach ($roles as $role) {
    if ($role
      ->hasPermission('view inappropriate reports')) {
      $roles_with_perm[] = $role
        ->id();
    }
  }
  return $roles_with_perm;
}