You are here

public function GroupPermissionHandler::getPermissionsByGroupType in Group 2.0.x

Same name and namespace in other branches
  1. 8 src/Access/GroupPermissionHandler.php \Drupal\group\Access\GroupPermissionHandler::getPermissionsByGroupType()

Gets all defined group permissions for a group type.

Unlike ::getPermissions(), this also includes the group permissions that were defined by the plugins installed on the group type.

Parameters

\Drupal\group\Entity\GroupTypeInterface $group_type: The group type to retrieve the permission list for.

Return value

array The full permission list, structured like ::getPermissions().

Overrides GroupPermissionHandlerInterface::getPermissionsByGroupType

See also

\Drupal\group\Access\GroupPermissionHandlerInterface::getPermissions()

File

src/Access/GroupPermissionHandler.php, line 141

Class

GroupPermissionHandler
Provides the available permissions based on yml files.

Namespace

Drupal\group\Access

Code

public function getPermissionsByGroupType(GroupTypeInterface $group_type) {
  $all_permissions = $this
    ->buildPermissionsYaml();

  // Add the plugin defined permissions to the whole.
  foreach ($group_type
    ->getInstalledContentPlugins() as $plugin) {
    $provider = $plugin
      ->getProvider();
    $section = $plugin
      ->getLabel()
      ->__toString();

    /** @var \Drupal\group\Plugin\Group\Relation\GroupRelationInterface $plugin */

    // @todo 2.0.0 CALL HANDLER.
    foreach ($plugin
      ->getPermissions() as $permission_name => $permission) {
      $permission += [
        'provider' => $provider,
        'section' => $section,
      ];
      $all_permissions[$permission_name] = $this
        ->completePermission($permission);
    }
  }
  return $this
    ->sortPermissions($all_permissions);
}