I'll just come right out and say that I don't think it's a good idea for entity_metadata to automatically provide tokens for all entities. If core modules are missing tokens (i.e. menu, field, book, etc), then they should go into Token module where they can be curated for D8 inclusion. If other contrib modules are too damn lazy to make their own token implementations, then they should just not have tokens or be patched to provide them. I think we're doing other developers and our end-users a disservice by automatically providing the tokens.

Plus we're running into issues like #975616: Entity metadata needlessly duplicates properties. So I'd like to discuss why, if anyone feels entity_metadata should be providing tokens at all.

Comments

fago’s picture

Well, first off the main point for me to add the token integration to entity_metadata was because of Rules - my initial cause to do the module. Rules makes use of entity_metadata property for data selection and the token integration is needed in order to have the same properties available to the user via data selection in token replacements too - thus this important in order to provide a consistent UX.
As it this point there was no token module for d7 and everything needed is available in entity_metadata, it was just straightforward to do it that way. However, I cannot think of another way to achieve this consistency else anyway.

Secondly, as the entity_metadata property info API is rather similar to tokens, it would be odd to force modules to provide both. Thus modules have the option to provide the properties and they'll get the tokens too.

>If other contrib modules are too damn lazy to make their own token implementations, then they should just not have tokens or be patched to provide them.

Entity metadata doesn't provide tokens upon other modules - except for if the module provides entity_metadata property info to it as described above. Entity metadata doesn't provide properties on top of other modules, it just provides core integration for its own hook.

So yes, as a consequence it provides also core tokens for all properties - if there is none yet. As written above this is important for having a consistent UX in modules like Rules, but I see that two modules providing *different* tokens for core can lead to inconsistencies too. So I think, we should work together so that we at least provide *the same* tokens, such that users won't get confused with duplicated tokens for the same thing.

fago’s picture

Title: Should entity_metadata provide tokens at all? » Move entity-metadata tokens into its own module.
Priority: Normal » Major

After leaving this lye for a while, I still think moving tokens into a separate small module makes sense. Providing tokens violates the module's "API module" label + moving it into a separate module helps to improve UX, so let's do it.

fago’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.