class EntityOperationDeriver in Drupal 7 to 8/9 Module Upgrader 8
Builds derivative definitions for the _entity_operation plugin, allowing us to rewrite calls to things like entity_save(), node_delete(), entity_label(), etc.
Hierarchy
- class \Drupal\drupalmoduleupgrader\DeriverBase implements ContainerDeriverInterface uses StringTranslationTrait
- class \Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions\EntityOperationDeriver
Expanded class hierarchy of EntityOperationDeriver
File
- src/
Plugin/ DMU/ Converter/ Functions/ EntityOperationDeriver.php, line 13
Namespace
Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\FunctionsView source
class EntityOperationDeriver extends DeriverBase {
/**
* @var array
*/
protected $config;
public function __construct(TranslationInterface $translator, array $config) {
parent::__construct($translator);
$this->config = $config;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('string_translation'), $container
->get('config.factory')
->get('drupalmoduleupgrader.entity_operations')
->get('definitions'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_definition) {
$derivatives = [];
foreach ($this->config as $entity_type => $operations) {
foreach ($operations as $operation) {
$function = $entity_type . '_' . $operation;
$variables = [
'@function' => $function,
'@operation' => $operation,
];
$derivative = $base_definition;
$derivative['function'] = $function;
$derivative['method'] = $operation;
$derivative['message'] = $this
->t('`@function` is now `EntityInterface::@operation`.', $variables);
$derivative['description'] = $this
->t('Rewrites calls to @function().', $variables);
$derivatives[$function] = $derivative;
}
}
return $derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
EntityOperationDeriver:: |
protected | property | ||
EntityOperationDeriver:: |
public static | function |
Creates a new class instance. Overrides DeriverBase:: |
|
EntityOperationDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverInterface:: |
|
EntityOperationDeriver:: |
public | function |
Overrides DeriverBase:: |
|
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. |