diff --git a/src/Plugin/Field/FieldType/TemplateWhispererFieldItem.php b/src/Plugin/Field/FieldType/TemplateWhispererFieldItem.php index 46aca42..8b73ed7 100644 --- a/src/Plugin/Field/FieldType/TemplateWhispererFieldItem.php +++ b/src/Plugin/Field/FieldType/TemplateWhispererFieldItem.php @@ -15,7 +15,7 @@ * id = "template_whisperer", * label = @Translation("Template Whisperer"), * description = @Translation("This field stores a Template Whisperer entity reference."), - * category = @Translation("General"), + * category = "general", * default_widget = "template_whisperer", * default_formatter = "template_whisperer", * ) diff --git a/template_whisperer.module b/template_whisperer.module index 221f399..7bfa46b 100644 --- a/template_whisperer.module +++ b/template_whisperer.module @@ -5,6 +5,8 @@ * Contains template_whisperer.module. */ +use Drupal\Core\StringTranslation\TranslatableMarkup; + require_once 'inc/suggestions/page.inc'; require_once 'inc/suggestions/entity.inc'; @@ -16,6 +18,19 @@ function template_whisperer_theme_suggestions_alter(array &$suggestions, array $ _template_whisperer_theme_suggestions_entity($suggestions, $variables, $hook); } +/** + * Implements hook_field_info_alter(). + * + * @todo Remove once minimum version supported is at least 10.2.0. + * @see https://www.drupal.org/node/3375748 + */ +function template_whisperer_field_info_alter(array &$info): void { + // Allow module to work with versions of older versions of Drupal. + if (\version_compare(\Drupal::VERSION, '10.1.9999', '<')) { + $info['general']['category'] = new TranslatableMarkup("General"); + } +} + require_once 'inc/rm_cardinality.inc'; require_once 'inc/help.inc'; require_once 'inc/tokens.inc';