It would be helpful to expose relations in an entity list wrapper property.
This can help you to create new search api facets on related entity fields or whatsoever.

I needed this in a project so I created a sandbox for this.
http://drupal.org/sandbox/jsacksick/1265422

Comments

naught101’s picture

Status: Active » Postponed (maintainer needs more info)

Sorry, I'm not really in a position to say yes or no, as I don't know what it does... can you give an example of what you can do with it?

jsacksick’s picture

This module loop over all entity types concerned by a relation and add a property list wrapper containing a list of related entities.
For instance, Search API (and a lot of other modules) fetches all its data from the Entity Metadata information.
So once this module is enabled, you can create with this, facets obtained by the relation.

chx’s picture

Status: Postponed (maintainer needs more info) » Active

I am willing to commit this if you convert the relation_rules_load_related rules action callback to use it.

jsacksick’s picture

What do you mean ? Can you explain me a little please ?

chx’s picture

Well, your module creates a list of related entities and that's exactly what relation_rules_load_related exposes to rules so the two quite overlap.

jsacksick’s picture

This patch should be ok.
I only have a doubt remaining, Do we have to return wrapped endpoints in relation_rules_load_related or is it ok like that ?

jsacksick’s picture

Status: Active » Needs review
jsacksick’s picture

Here is a second patch with wrapped enpoints returned instead.

chx’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
chx’s picture

A test has been committed to the repo which runs a rule on node creation, creating a relation between a previously specified node and the new node. Then it proceeeds to load the related entities of the new node. If all goes well this will be the previously specified node. Then it deletes the entity The test asserts the other nodes created by the test setup are unharmed and the one we wanted is gone. This almost passes the current HEAD but not with the patch provided here. Almost, because there is a rules warning about a cache problem. Interestingly, if I apply the patch from here, I get two of this error message.

jsacksick’s picture

Status: Needs work » Needs review
StatusFileSize
new5.18 KB

Except for the _rules_rebuild_cache() issue, the other errors are now gone with this patch.

chx’s picture

Status: Needs review » Fixed

Thanks! Committed.

Status: Fixed » Closed (fixed)

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

acrazyanimal’s picture

Component: Code » API

See #1361796: rules: load related entities, entity fields unavailable for a patch to "Loads related entities".