Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use new API for defining field type categories
Browse files Browse the repository at this point in the history
WengerK committed Feb 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fe18516 commit 0fbe6f2
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Plugin/Field/FieldType/TemplateWhispererFieldItem.php
Original file line number Diff line number Diff line change
@@ -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",
* )
15 changes: 15 additions & 0 deletions template_whisperer.module
Original file line number Diff line number Diff line change
@@ -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';

0 comments on commit 0fbe6f2

Please sign in to comment.