Problem/Motivation
Before http://cgit.drupalcode.org/languagefield/commit/?h=7.x-1.x&id=611eede097... the language code was available from an wrapped entity object the following way:
$langcode = $wrapped_node->field_language->value->value();
Now it's
$langcode = $wrapped_node->field_language->value();
This however makes languagefields pretty much unusable in rules selectors.
Proposed resolution
Remaining tasks
Fixing it so that [node:field-language] tokens still work afterwards.
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | languagefield-2805191-2-rules.patch | 5.93 KB | czigor |
Comments
Comment #2
czigor commentedI looked at email, link, country, address and commerce_line_item modules on how they support both tokens and entity properties for custom fields. What I learnt is that for a simple, one-column field providing a simple data type like language_field, the hook_field_info() does not need a 'property_callbacks' attribute. Instead, it needs to set a proper 'property_type' attribute (still in hook_field_info()) and implement hook_token_info() and hook_tokens().
The result is that token [node:field_language] yields "English", [node:field_language:value] and $wrapped_node->field_language->value() yield 'en'. What's more, $wrapped_node->field_language has a 'token' property type, which enables us to carry on using it with Rules. Everyone happy.
Comment #4
johnvComment #5
johnv