You are here

public function OgUiController::rolesPermissionsOverviewPage in Organic groups 8

Returns the overview of OG roles and permissions.

Parameters

string $type: The type of overview, either 'roles' or 'permissions'.

Return value

array The overview as a render array.

1 string reference to 'OgUiController::rolesPermissionsOverviewPage'
og_ui.routing.yml in og_ui/og_ui.routing.yml
og_ui/og_ui.routing.yml

File

og_ui/src/Controller/OgUiController.php, line 76

Class

OgUiController
The OG UI controller.

Namespace

Drupal\og_ui\Controller

Code

public function rolesPermissionsOverviewPage($type) {
  $action = $type === 'roles' ? $this
    ->t('Edit roles') : $this
    ->t('Edit permissions');
  $header = [
    $this
      ->t('Group type'),
    $this
      ->t('Operations'),
  ];
  $rows = [];
  $build = [];
  foreach ($this->groupTypeManager
    ->getGroupMap() as $entity_type => $bundles) {
    $definition = $this->entityTypeManager
      ->getDefinition($entity_type);
    $bundle_info = $this->entityTypeBundleInfo
      ->getBundleInfo($entity_type);
    foreach ($bundles as $bundle) {
      $rows[] = [
        [
          'data' => $definition
            ->getLabel() . ' - ' . $bundle_info[$bundle]['label'],
        ],
        [
          'data' => Link::createFromRoute($action, 'og_ui.' . $type . '_form', [
            'entity_type' => $entity_type,
            'bundle' => $bundle,
          ]),
        ],
      ];
    }
  }
  $build['roles_table'] = [
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => $this
      ->t('No group types available.'),
  ];
  return $build;
}