While working with relation heavy applications I've noticed that I quite regularly have to load endpoint entities of a relation. Would it make sense to include something like this in Relation module core?
function relation_load_endpoint_entities($relation, $entity_type = NULL)
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | relation_get_endpoints-1418646-4.patch | 1.39 KB | mikran |
| #1 | relation_load_endpoint_entities-1418646-2.patch | 1.18 KB | mikran |
Comments
Comment #1
mikran commentedHere is patch if you like it useful. I'd like shorter name but relation_entities() or similar is just too misleading.
Comment #2
mikran commentedcommitted
Comment #3
Jorrit commentedI think the following line in the patch is unintended:
+ $entity = entity_load($endpoint['entity_type'], array($endpoint['entity_id']));The $entity variable is not used there. Loading happens in the second loop.
Also, this function does not respect the order in which the entity endpoints are returned from the database.
Comment #4
mikran commentedNice catch, thanks. The entity_load is now removed.
I don't know about the order. It's not changed and if r_index values are needed those are available in relation object even without loading endpoints.
I found relation_rules_get_endpoints() which does basically the same thing. Does it make any sense to change name of this function to relation_get_endpoints and use that from rules as well? Patch attached for this change.
Comment #5
mikran commentedAPI function rename is now committed. I wanted to hurry with this before any code gets created using this with the old name.