It would be great to have the [entity:uuid] token avaliable in list of tokens.

Comments

friera created an issue. See original summary.

jerome legendre’s picture

Hello,

I just builted the following module for this. I suppose this will become obsolete with Token future versions.
https://www.drupal.org/project/tokenuuid

berdir’s picture

We already expose the uuid token as part of the field tokens, but since it is a base field, we only do that for entity types that have no tokens yet.

Open for patches to also add it for entity types that don't have a uuid token yet though.

heddn’s picture

I'm seeing where there's a check for FieldStorageConfigInterface and continuing. So I don't think it is the case any more that UUID is added with field tokens.

UUID fields are BaseFieldDefinition, which is not an implementation of FieldStorageConfigInterface.

heddn’s picture

function field_token_info_alter(&$info) {
  $type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinitions();

  // Attach field tokens to their respecitve entity tokens.
  foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) {
...

    $fields = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions($entity_type_id);
    foreach ($fields as $field_name => $field) {
...
      if (!($field instanceof FieldStorageConfigInterface) && $provider != 'token') {
        continue;
      }
heddn’s picture

heddn’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: token-base-field-support-use-storage-definition-interface-2493567-36.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

berdir’s picture

This is there by design, we only expose base fields for entity types where we also define the token type, so we don't end up with duplicated custom tokens and generic tokens.

chrisolof’s picture

it-cru’s picture

Should we mark this as duplicate from #3047568: Consistent tokens support across all entities and fields, because patch from the the other issue provides UUID token and also other stuff.

mxr576’s picture

Status: Needs work » Closed (duplicate)

As suggested, closing this a duplicate of #3047568: Consistent tokens support across all entities and fields. That issue is still active...