Ubercart adds node properties in hook_entity_property_info_alter() so they can be used in Rules data selectors, Search API, etc, but we also want to implement chained token support for example [node:product:sell-price:formatted] and [node:product:sell-price:raw].

However, Entity tokens automatically provides [node:sell-price] which duplicates the raw token only; seemingly the only way to prevent this at present is to use hook_token_info_alter() to discover and remove node tokens that have 'entity-token' set.

Ubercart issue: #1230118-11: Model token no longer available in Pathauto and later comments

Comments

Island Usurper’s picture

Status: Active » Needs review
StatusFileSize
new1.54 KB

Here 'tis.

fago’s picture

Status: Needs review » Needs work

Entity token only provides tokens if there is none yet, so if you provide [node:sell-price] it shouldn't. Still, I think that option makes sense, but we need to fix the description to reflect the actual entity-tokens behaviour (it only provides tokens if there is none yet).

Maybe, also we should call the flag "entity token" => FALSE, as it doesn't disable tokens generally.

Unrelated, but tokens like [node:product:sell-price:raw] are deprecated in D7 - we have $options['sanitize'] for that now.

Island Usurper’s picture

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

Maybe we should call it "numeric" instead of "raw", as opposed to formatted. *shrug*

Updated patch with better documentation and flag name change.

fago’s picture

StatusFileSize
new1.61 KB

Thanks, I tried to further improve the description. Makes sense?

Island Usurper’s picture

Status: Needs review » Reviewed & tested by the community

Yeah, looks good to me. Thanks.

fago’s picture

Status: Reviewed & tested by the community » Fixed

thanks, committed.

Status: Fixed » Closed (fixed)

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

longwave’s picture

Status: Closed (fixed) » Active

This feature seems to have been removed as of this commit: http://drupalcode.org/project/entity.git/commitdiff/867533d - grepping the code for "entity token" only returns two comments now.

The same commit also causes an array_flip() error in Ubercart when trying to generate list<uc_order_product> tokens. I attempted to use 'entity token' => FALSE to avoid this, but as the code no longer exists this didn't work! (see #1388984: array_flip() error when rendering invoices using Entity 7.x-1.x-dev)

fago’s picture

Title: Provide a way for properties to specify that entity tokens are not required » 'entity token' flag does not work any more
Category: feature » bug

ouch.

d.novikov’s picture

Up.
Is this commited to the latest dev?