Hello, not sure if this is a support request or feature request.

I have 3 discrete relations of the same relation type set up,
A=>B,
A=>C, and
A=>D.
B, C, and D are each children of A, but are not related to each other.

I need to get the relation ids or the relation objects of the above relations in an array using A's entity id. Is there a function for this?

I see two functions in relation.module,
relation_get_endpoints($relation, $entity_type = NULL),
which seems to get each of the endpoints for only a single relation from the relation object
relation_get_related_entity($entity_type, $entity_id, $relation_type = NULL, $r_index = NULL)
which seems only to be good for getting the first endpoint entity object of the first relation.

Am I missing something? If this doesn't exist, I humbly request a helper function.

Thanks!

Comments

ridgek’s picture

Issue summary: View changes

clarification

mikran’s picture

Yes, relation_query() is there for that.

$rids = array_keys(relation_query('entity_type_of_A', $entity_id_of_A)->execute());

This issue is related, #1288894: Turn relation_get_related_entity into relation_get_related_entities

ridgek’s picture

Status: Active » Postponed

Ah! I had tried that one unsuccessfully. I must have run it on the wrong parameters. I'll try again. Also looking through the linked issue now. Thanks for your help and quick response! :)

ridgek’s picture

Status: Postponed » Closed (works as designed)

It works! Thanks again for your help. Here's the goods!

https://drupal.org/sandbox/ridgekuhn/2099907

ridgek’s picture

Issue summary: View changes

correction