Problem/Motivation

We're now defining token types for all entity types, even config entities. The only tokens they have are url and :origin however, which is a useless token on its own if there is nothing else.

Proposed resolution

Exclude config entities for now. We could look into providing config schema/typed data based integration there as well later, but lets ignore that for now.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Berdir created an issue. See original summary.

Bambell’s picture

Status: Active » Needs review
StatusFileSize
new661 bytes
new284.12 KB
new108.69 KB

Here we go. I'm not too sure about this, though. For instance, in #2611866: Add image style tokens for image fields, I'm relying on image_style tokens. I can of course re-create the token, but I'm under the impression this might break a couple things.

berdir’s picture

Status: Needs review » Needs work

But what you are using for is something entirely different I think. This would be tokens for *one* image style. You're using it just to "pipe" through the image style selection, which is very different from what other tokens there would do.

So yes, you would have to define one anyway.

+++ b/token.tokens.inc
@@ -64,7 +64,9 @@ function token_token_info_alter(&$info) {
+    // a config entity.
+    if (!$entity_info->get('token_type') || $entity_info->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) {

Lets change it to only do it for content entity types.

People find isSubclassOf() confusing and it might get deprecated at some point. I think we can do a check of $entity_info directly, that is a ContentEntityTypeInterface object (the @var above is strange, can you try to remove that, shouldn't be necessary..)

Bambell’s picture

Status: Needs work » Needs review
StatusFileSize
new991 bytes
new1.07 KB

Yep. Here we go.

berdir’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Looks good.

I think it makes sense to have a simple assertion somewhere to make sure that a token type like Roles or so doesn't show up.

Bambell’s picture

Status: Needs work » Needs review
StatusFileSize
new1.79 KB
new841 bytes

UnitTest seems most appropriate for that.

Status: Needs review » Needs work

The last submitted patch, 6: do_not_define_config-2761969-6.patch, failed testing.

The last submitted patch, 6: do_not_define_config-2761969-6.patch, failed testing.

Bambell’s picture

Status: Needs work » Needs review
StatusFileSize
new1.8 KB

Branch was up-to-date, not too sure what happened.

  • Berdir committed 9c3ae00 on 8.x-1.x authored by Bambell
    Issue #2761969 by Bambell: Do not define config entities as token types...
berdir’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

Thanks, committed.

Status: Fixed » Closed (fixed)

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