You are here

public function UserRole::__construct in Fasttoggle 8.2

Constructs a Drupal\Component\Plugin\PluginBase object.

Parameters

array $configuration: A configuration array containing information about the plugin instance.

string $plugin_id: The plugin_id for the plugin instance.

mixed $plugin_definition: The plugin implementation definition.

Overrides SettingTrait::__construct

File

src/Plugin/Setting/UserRole.php, line 68
Fasttoggle User Status

Class

UserRole
Abstract interface for settings. Plugin strings are used for quick filtering without the need to instantiate the class.

Namespace

Drupal\fasttoggle\Plugin\Setting

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition) {
  $this
    ->trait_constructor($configuration, $plugin_id, $plugin_definition);
  $role_objects = Role::loadMultiple();
  unset($role_objects['anonymous']);
  unset($role_objects['authenticated']);
  $this->attributes = array_combine(array_keys($role_objects), array_map(function ($a) {
    return $a
      ->label();
  }, $role_objects));
  parent::__construct($configuration, $plugin_id, $plugin_definition);
}