class DisableDeriver in Drupal 7 to 8/9 Module Upgrader 8
Builds derivative definitions for the _disable plugin, based on a bundled configuration file. This allows us (plugin authors) to easily define which function calls can be commented out.
Hierarchy
- class \Drupal\drupalmoduleupgrader\DeriverBase implements ContainerDeriverInterface uses StringTranslationTrait
- class \Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions\DisableDeriver
Expanded class hierarchy of DisableDeriver
File
- src/
Plugin/ DMU/ Converter/ Functions/ DisableDeriver.php, line 12
Namespace
Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\FunctionsView source
class DisableDeriver extends DeriverBase {
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_definition) {
$derivatives = [];
$config = \Drupal::config('drupalmoduleupgrader.functions')
->get('definitions');
foreach ($config as $key => $info) {
// Only disable functions that have been explicitly marked for disabling.
if (empty($info['disable'])) {
continue;
}
// $key can either be the name of a single function, or an arbitrary string
// identifying a group of functions to handle.
if (empty($info['functions'])) {
$info['functions'] = [
$key,
];
}
foreach ($info['functions'] as $function) {
$derivative = $base_definition;
$variables = [
'@function' => $function . '()',
];
$derivative['function'] = $function;
$derivative['description'] = $this
->t('Disables calls to @function().', $variables);
if (isset($info['fixme'])) {
$derivative['fixme'] = $this
->t($info['fixme'], $variables);
}
$derivative['documentation'] = $info['documentation'];
$derivatives[$function] = $derivative;
}
}
return $derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
3 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
DeriverBase:: |
public | function | 3 | |
DisableDeriver:: |
public | function |
Gets the definition of all derivatives of a base 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. |