3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter;
5 use Drupal\drupalmoduleupgrader\ConverterBase;
6 use Drupal\drupalmoduleupgrader\TargetInterface;
7 use Drupal\drupalmoduleupgrader\Utility\StringTransformTrait;
11 * id = "hook_field_formatter_info",
12 * description = @Translation("Creates formatter class templates from hook_field_formatter_info()."),
13 * hook = "hook_field_formatter_info"
16 class HookFieldFormatterInfo extends ConverterBase {
18 use StringTransformTrait;
23 public function convert(TargetInterface $target) {
25 $formatters = $this->executeHook($target, $this->pluginDefinition['hook']);
27 catch (\LogicException $e) {
28 $this->log->warning($e->getMessage(), [
29 'target' => $target->id(),
30 'hook' => $this->pluginDefinition['hook'],
35 foreach ($formatters as $id => $formatter) {
37 '#module' => $target->id(),
38 '#class' => $this->toTitleCase($id),
39 '#theme' => 'dmu_formatter',
42 'label' => $formatter['label'],
43 'description' => $formatter['description'] ?: NULL,
44 'field_types' => $formatter['field types'],
47 $this->writeClass($target, $this->parse($render));