You are here

public function RoleSplitDeriver::getDerivativeDefinitions in Config Role Split 8

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/ConfigFilter/RoleSplitDeriver.php, line 56

Class

RoleSplitDeriver
Deriver for Config Role Split filters.

Namespace

Drupal\config_role_split\Plugin\ConfigFilter

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  foreach ($this->entityStorage
    ->loadMultiple() as $name => $entity) {
    $config_name = $entity
      ->getConfigDependencyName();
    $config = $this->configFactory
      ->get($config_name);
    $this->derivatives[$name] = $base_plugin_definition;
    $this->derivatives[$name]['label'] = $entity
      ->label();
    $this->derivatives[$name]['config_name'] = $config_name;

    // The roles and mode are read from the storage if it exists.
    $this->derivatives[$name]['roles'] = $config
      ->get('roles');
    $this->derivatives[$name]['mode'] = $config
      ->get('mode');

    // The weight and status can be overwritten in settings.php, however,
    // the cache has to ble cleared for changes in overrides to take effect.
    $this->derivatives[$name]['weight'] = $config
      ->get('weight');
    $this->derivatives[$name]['status'] = $config
      ->get('status');
    $this->derivatives[$name]['config_dependencies']['config'] = [
      $config_name,
    ];
  }
  return $this->derivatives;
}