public function EntityOperationDeriver::getDerivativeDefinitions in Drupal 7 to 8/9 Module Upgrader 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 DeriverInterface::getDerivativeDefinitions
See also
getDerivativeDefinition()
File
- src/
Plugin/ DMU/ Converter/ Functions/ EntityOperationDeriver.php, line 38
Class
- EntityOperationDeriver
- Builds derivative definitions for the _entity_operation plugin, allowing us to rewrite calls to things like entity_save(), node_delete(), entity_label(), etc.
Namespace
Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\FunctionsCode
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;
}