Problem/Motivation
Currently the rules action "Fetch entity by id" defaults the data type of the identifier to integer. However, since remote entities can use the remote id it should be possible to use text - similar to when an entity supports loading by name.
Proposed resolution
Either we duplicate the action with all the surrounding code or we use hook_rules_action_info_alter() to make some adjustments.
I'd suggest the later one as it seems to be less maintenance work in the long run.
Attached patch introduces our own "info alter" callback remote_entity_rules_action_entity_fetch_info_alter(). The code in entity_rules_rules_action_info_alter() tries to maintain possible other changes by backing up a pre-existing "info alter" callback.
After fiddling with the code it turns out duplicating the function is quite easy and that we should be able to re-use most of the callbacks from the original entity fetch (e.g. access check) while we can adjust the execution callback nicely.
Remaining tasks
Reviews needed.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | remote_entity-enhance-rules-integration-fetch-entity-action-2561735-8.patch | 4.39 KB | das-peter |
Comments
Comment #2
das-peter commentedOh, issue with argument not given as reference. Fixed in updated patch.
Comment #3
joachim commentedCan this hook go in a Rules .inc file?
Comment #4
das-peter commentedIndeed, it works. Didn't expect that for a
_alter()hook :)Updated the patch.
Comment #5
das-peter commentedUnfortunately I figured out that placing those hooks in the rules inc file wont always work :|
It seems that under certain circumstances the hooks are called while the inc file isn't loaded.
I gave the duplication of the entity fetch action from rules itself a shot and it turns out we should be able to do it nicely. As I've duplicated the code now it seems quite maintainable :) Maybe even better than adjusting the info hooks.
So the next patch introduces a special action to load entities by remote id - and even allows to force loading from remote.
Comment #6
das-peter commentedDarn, last patch is missing some bits in the module file. Here an update one.
Comment #8
das-peter commentedFreakin' windows...