Problem/Motivation
Drupal core provides the ability to represent data in tokens. However, it does not magically generate tokens. Tokens and their values must be explicitly defined. That means we would have to manually maintain tokens for each entity provided in our various submodules. We have gotten around the usage of tokens by using Twig whenever possible.
It is starting to seem like we should just make Token an explicit dependency. In the project-base repository we added it in response to various issues and Slack/IRC conversations.
I could see this being used for:
- Customizing the variation title generation (currently hardcoded to Product Name - Attributes)
- Customizing the generate order number
- Most payment gateways support authorization/payment notes, could be used for that
Proposed resolution
Add token as a dependency outright. No initial usage and integration but as a developer and site builder experience helper. No more "wait, where are the product tokens?"
Remaining tasks
- Link relevant issues which would prove this argument
- Link issues which could implement the token browser and tokens
- Get community feedback
Comment | File | Size | Author |
---|---|---|---|
#4 | 2923854-4-token.patch | 1.04 KB | bojanz |
|
Comments
Comment #2
websiteworkspace CreditAttribution: websiteworkspace commentedThank you for making this important feature set a priority.
Comment #3
bojanz CreditAttribution: bojanz at Centarro commentedWe are going to proceed with adding a dependency on Token in 2.15.
Token is already one of the most commonly installed D8 contribs, since it is required by pathauto and metatag.
We already have it in both of our project templates (project-base and demo-project), and we require it for commerce_demo.
That means that the majority of our install base should already be ready for this change.
Of course, since updates are handled by Composer, it will download the missing dependency if needed.
This will make our lives easier in #2730131: Add a commerce_number_pattern submodule for sequential (order/invoice) number generation, which requires Token already.
Comment #4
bojanz CreditAttribution: bojanz at Centarro commentedWorked fine in manual testing. Let's see what the tests say.
Comment #5
bojanz CreditAttribution: bojanz at Centarro commentedComment #6
bojanz CreditAttribution: bojanz at Centarro commentedWe're good to go. Brave new world!
Comment #8
BerdirPing me if you need something in token :)
Comment #9
bojanz CreditAttribution: bojanz at Centarro commented@Berdir
Thank you!