You are here

public function GroupContentEnablerBase::getPermissions in Group 8

Provides a list of group permissions the plugin exposes.

If you have some group permissions that would only make sense when your plugin is installed, you may define those here. They will not be shown on the permission configuration form unless the plugin is installed.

Return value

array An array of group permissions, see GroupPermissionHandlerInterface for the structure of a group permission.

Overrides GroupContentEnablerInterface::getPermissions

Deprecated

in Group 1.0, will be removed before Group 2.0. Retrieve the permission_provider handler from the plugin manager instead.

See also

GroupPermissionHandlerInterface::getPermissions()

File

src/Plugin/GroupContentEnablerBase.php, line 247

Class

GroupContentEnablerBase
Provides a base class for GroupContentEnabler plugins.

Namespace

Drupal\group\Plugin

Code

public function getPermissions() {

  /** @var \Drupal\group\Plugin\GroupContentEnablerManagerInterface $manager */
  $manager = \Drupal::service('plugin.manager.group_content_enabler');

  // Backwards compatibility layer:
  // - Use the declared permission provider if available.
  if ($manager
    ->hasHandler($this->pluginId, 'permission_provider')) {
    return $manager
      ->getPermissionProvider($this->pluginId)
      ->buildPermissions();
  }

  // Backwards compatibility layer:
  // - Fall back to the default permission provider if none was found.
  // - Still call the protected methods so old code can alter the permissions.

  /** @var \Drupal\group\plugin\GroupContentPermissionProviderInterface $permission_provider */
  $permission_provider = $manager
    ->createHandlerInstance('Drupal\\group\\Plugin\\GroupContentPermissionProvider', $this->pluginId, $this->pluginDefinition);
  $this->_permissions = $permission_provider
    ->buildPermissions();
  $this->_permissions = $this
    ->getGroupContentPermissions();
  if ($this
    ->definesEntityAccess()) {
    $this->_permissions = $this
      ->getTargetEntityPermissions();
  }
  return $this->_permissions;
}