class SyncFilterDeriver in Configuration Synchronizer 8.2
Deriver for SyncFilter filters.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\config_sync\Plugin\ConfigFilter\SyncFilterDeriver implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of SyncFilterDeriver
File
- src/
Plugin/ ConfigFilter/ SyncFilterDeriver.php, line 18
Namespace
Drupal\config_sync\Plugin\ConfigFilterView source
class SyncFilterDeriver extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* The configuration synchronizer lister.
*
* @var \Drupal\config_sync\configSyncListerInterface
*/
protected $configSyncLister;
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* The theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
/**
* The state storage object.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* SyncFilter constructor.
*
* @param \Drupal\config_sync\ConfigSyncListerInterface $config_sync_lister
* The configuration synchronizer lister.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* The theme handler.
* @param \Drupal\Core\State\StateInterface $state
* The state storage object.
*/
public function __construct(ConfigSyncListerInterface $config_sync_lister, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, StateInterface $state) {
$this->configSyncLister = $config_sync_lister;
$this->moduleHandler = $module_handler;
$this->themeHandler = $theme_handler;
$this->state = $state;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('config_sync.lister'), $container
->get('module_handler'), $container
->get('theme_handler'), $container
->get('state'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$plugin_data = $this->state
->get('config_sync.plugins', []);
$type_labels = [
'module' => $this
->t('Module'),
'theme' => $this
->t('Theme'),
];
foreach ($this->configSyncLister
->getExtensionChangelists() as $type => $extension_changelists) {
foreach (array_keys($extension_changelists) as $name) {
$key = $type . '_' . $name;
$this->derivatives[$key] = $base_plugin_definition;
$this->derivatives[$key]['extension_type'] = $type;
$this->derivatives[$key]['extension_name'] = $name;
switch ($type) {
case 'module':
$label = $this->moduleHandler
->getName($name);
$type_label = $this
->t('Module');
break;
case 'theme':
$label = $this->themeHandler
->getName($name);
$type_label = $this
->t('Theme');
break;
}
$this->derivatives[$key]['label'] = $this
->t('@type_label: @label', [
'@type_label' => $type_label,
'@label' => $label,
]);
// Status can be overridden in the state.
$this->derivatives[$key]['status'] = !isset($plugin_data[$type][$name]['status']) || $plugin_data[$type][$name]['status'] === TRUE;
}
}
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:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
SyncFilterDeriver:: |
protected | property | The configuration synchronizer lister. | |
SyncFilterDeriver:: |
protected | property | The module handler. | |
SyncFilterDeriver:: |
protected | property | The state storage object. | |
SyncFilterDeriver:: |
protected | property | The theme handler. | |
SyncFilterDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
SyncFilterDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
SyncFilterDeriver:: |
public | function | SyncFilter constructor. |