Problem/Motivation
Current token support is handled by Token module. Provides basic field level and field component tokens.
This can be extended to fairly easily support name format tokens (I think).
i.e. something like this (orange boxes show the extended tokens)

Due to the nature of the implementation of the Token module, trying to implement multi-value lists could be difficult and maybe requires that the logic is duplicated from the Token module to the Name field module to maintain control.
Proposed resolution
To be decided.
Remaining tasks
User interface changes
API changes
Data model changes
Original post
Token API has been updated to consider cacheability metadata.
The change record for more information: Token replacement needs to consider cacheability metadata
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | issue-2539278-token.png | 84.27 KB | bluegeek9 |
Issue fork name-2539278
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
mbovan commentedAdded
$bubbleable_metadataparam in_name_tokens().Comment #2
mbovan commentedJust removing caching for
$accountas it is not needed and removing set for optional parameters. Anyway, code inside_name_tokens()seems broken, calling deprecated methods etc.Comment #3
alan d. commentedMaybe we should fully review the token area...
Comment #4
alan d. commentedComment #5
alan d. commentedlol, or actually port and implement the tokens:
Comment #6
alan d. commentedComment #7
alan d. commentedSince token module provides most of the functionality and extending this could prove to be a bit of a quagmire, decoupling from #2949574: [meta] Name Field Full Release
The old code isn't actually triggered and support is provided indirectly via the Token module.
Support for using format settings per individual name items wasn't too bad, supporting list support was a nightmare as Token module switches token structure based on the cardinality.
Comment #8
karuna patel commented#5 suggestion will work, create your own token and set name field in the token.
Here is another example of hook_token in d8.
Comment #9
alan d. commentedlol, yes. But no as per #7
Fairly good support via Token module and NameItem::propertyDefinitions()
https://cgit.drupalcode.org/name/tree/src/Tests/NameNodeTokenReplaceTest...
About 400-500 loc to reimplement all of the features from Token provides for free;
Or make Token module a dependency and call internal private functions that could break at any time;
Or updating the hook weight, a token alter and it was fairly easy to add new additional tokens to the list, albeit these would be limited to single field items:
i.e. field_token_info_alter()
i.e the FIELD_NAME:PROPERTY and FIELD_NAME:0:PROPERTY type tokens that change with cardinality (when will people stop doing this....)
Comment #10
bluegeek9 commentedComment #12
bluegeek9 commentedComment #14
bluegeek9 commentedComment #15
bluegeek9 commented