You are here

protected function ExportUser::pluginAccess in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_user_export/src/Plugin/Action/ExportUser.php \Drupal\social_user_export\Plugin\Action\ExportUser::pluginAccess()
  2. 10.3.x modules/social_features/social_user_export/src/Plugin/Action/ExportUser.php \Drupal\social_user_export\Plugin\Action\ExportUser::pluginAccess()
  3. 10.0.x modules/social_features/social_user_export/src/Plugin/Action/ExportUser.php \Drupal\social_user_export\Plugin\Action\ExportUser::pluginAccess()
  4. 10.1.x modules/social_features/social_user_export/src/Plugin/Action/ExportUser.php \Drupal\social_user_export\Plugin\Action\ExportUser::pluginAccess()
  5. 10.2.x modules/social_features/social_user_export/src/Plugin/Action/ExportUser.php \Drupal\social_user_export\Plugin\Action\ExportUser::pluginAccess()

Check the access of export plugins based on config and permission.

Parameters

array $definitions: The plugin definitions.

Return value

array Returns only the plugins the user has access to.

1 call to ExportUser::pluginAccess()
ExportUser::__construct in modules/social_features/social_user_export/src/Plugin/Action/ExportUser.php
Constructs a ExportUser object.

File

modules/social_features/social_user_export/src/Plugin/Action/ExportUser.php, line 266

Class

ExportUser
Exports a user accounts to CSV.

Namespace

Drupal\social_user_export\Plugin\Action

Code

protected function pluginAccess(array $definitions) : array {

  // When the user has access to administer users we know they may export all
  // the available data.
  if ($this->currentUser
    ->hasPermission('administer users')) {
    return $definitions;
  }

  // Now we go through all the definitions and check if they should be removed
  // or not based upon the config set by the site manager.
  $allowed_plugins = $this->config
    ->get('plugins');
  foreach ($definitions as $key => $definition) {
    if (!array_key_exists($definition['id'], $allowed_plugins) || empty($allowed_plugins[$definition['id']])) {
      unset($definitions[$key]);
    }
  }
  return $definitions;
}