class RoleSplitDeriver in Config Role Split 8
Deriver for Config Role Split filters.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\config_role_split\Plugin\ConfigFilter\RoleSplitDeriver implements ContainerDeriverInterface
Expanded class hierarchy of RoleSplitDeriver
File
- src/
Plugin/ ConfigFilter/ RoleSplitDeriver.php, line 14
Namespace
Drupal\config_role_split\Plugin\ConfigFilterView source
class RoleSplitDeriver extends DeriverBase implements ContainerDeriverInterface {
/**
* The menu storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $entityStorage;
/**
* The config Factory to load the overridden configuration.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* SplitFilter constructor.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $entity_storage
* The entity storage to load the split entities from.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory to load the configuration including overrides from.
*/
public function __construct(EntityStorageInterface $entity_storage, ConfigFactoryInterface $config_factory) {
$this->entityStorage = $entity_storage;
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager')
->getStorage('role_split'), $container
->get('config.factory'));
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
RoleSplitDeriver:: |
protected | property | The config Factory to load the overridden configuration. | |
RoleSplitDeriver:: |
protected | property | The menu storage. | |
RoleSplitDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
RoleSplitDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
RoleSplitDeriver:: |
public | function | SplitFilter constructor. |