public function HookFieldWidgetInfo::convert in Drupal 7 to 8/9 Module Upgrader 8
Performs required conversions.
Parameters
TargetInterface $target: The target module to convert.
Overrides ConverterInterface::convert
File
- src/
Plugin/ DMU/ Converter/ HookFieldWidgetInfo.php, line 23
Class
- HookFieldWidgetInfo
- Plugin annotation @Converter( id = "hook_field_widget_info", description = @Translation("Creates formatter class templates from hook_field_widget_info()."), hook = "hook_field_widget_info" )
Namespace
Drupal\drupalmoduleupgrader\Plugin\DMU\ConverterCode
public function convert(TargetInterface $target) {
try {
$widgets = $this
->executeHook($target, $this->pluginDefinition['hook']);
} catch (\LogicException $e) {
$this->logger
->warning($e
->getMessage(), [
'target' => $target
->id(),
'hook' => $this->pluginDefinition['hook'],
]);
return;
}
foreach ($widgets as $id => $widget) {
$render = [
'#module' => $target
->id(),
'#class' => $this
->toTitleCase($id),
'#theme' => 'dmu_widget',
'#info' => [
'id' => $id,
'label' => $widget['label'],
'description' => $widget['description'] ?: NULL,
'field_types' => $widget['field types'],
],
];
$this
->writeClass($target, $this
->parse($render));
}
}