field module should not be required for _field_token_info_alter to run

Created on 26 November 2024, 6 months ago

Problem/Motivation

I noticed that field tokens are not generated unless the field module is installed. Technically entities have field without that module, which just provides fields via config.

  // Call proxy implementations.
  if (\Drupal::moduleHandler()->moduleExists('field')) {
    _field_token_info_alter($info);
  }

It should be safe to _always_ call _field_token_info_alter

This seems related to ✨ Consistent tokens support across all entities and fields Needs work , but not. Because that still won't generate base field tokens

Steps to reproduce

Don't use field module and expect tokens for your custom entity type

Proposed resolution

Always generate field tokens

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mglaman
  • πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

    And then I saw

          $provider = '';
          if (isset($info['types'][$token_type]['module'])) {
            $provider = $info['types'][$token_type]['module'];
          }
          if (!($field instanceof FieldStorageConfigInterface) && $provider != 'token') {
            continue;
          }
    

    Adding as feedback to that issue.

Production build 0.71.5 2024