Closed (duplicate)
Project:
Relation
Version:
7.x-1.x-dev
Component:
Entity API / Rules
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
17 Sep 2011 at 21:49 UTC
Updated:
20 Oct 2015 at 10:43 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
boombatower commentedComment #2
Letharion commentedAssigning it to myself so I can provide the rules support.
Comment #3
naught101 commentedWhy is this in relation_get_available_types()?? This definitely should not be the default behaviour...
Comment #4
dixon_I think this is a use case that describes the need for a broader Rules integration. I think the Rules integration should work something like this:
On any event where an entity object is available, we should be able to load all related entities, or just entities related through a specific relation type, into a Rules list (array). That's it! Because when we have all those entities in that Rules list, we can loop over them and run any action on them.
The pseudo Rules-configuration for deleting all related entities would be:
---
Event
Entity is deletedCondition
Entity is of type
FooAction 1
Load all entities related through the relation type
BarThis action provides a Rules list called
related_enties(configurable)Action 2
Loop over list
related_entitiesAction 3 (on each item in the list)
Delete entity
---
And the only thing missing is the "Load all entities" action.
Comment #5
dixon_Cross posted
Comment #6
boombatower commented#3: was stub code
#4: Seems like a much better approach (never done rules stuff, so was looking to just solve my usecase).
Comment #7
Letharion commentedIn London I wrote the code dixon_ suggest in #4. I'm working on a proper test, and will push it then :)
Comment #8
boombatower commentedLooking forward to seeing the code. Assuming this allows you to do more then just react to delete action then.
Comment #9
boombatower commentedClosing related issue as I would guess most of it will be covered by this #1260262: More Rules actions!. If not there are some thoughts.
Comment #10
itangalo commentedSubscribing. Cool stuff.
Comment #11
Letharion commentedI opened #1293134: Rules actions with entity argument get their entity arguments unwrapped in the rules queue. It should probably be moved to entity.
The new rules action receives it's source entity unwrapped, meaning there is no way to determine it's entity type. I could have done something wrong, but I believe it's an oversight in the entity api.
Comment #12
mrfelton commentedSubscribing. Looking for a way to maintain relationships as entities change. So if you have two entities that are related, and one of them gets updated, you can detect this with rules, delete the relationship then recreate/update it to ensure it's still applicable/accurate
Comment #13
MeDAN commentedSubscribing.
Comment #14
itangalo commentedTalking to chx on IRC now, and he's working on an action for loading all entities related with a relation type X – the action described in #4.
Just for information.
Comment #15
prodigeek commentedAny update on this? I'm eager for a way to delete relations using rules based on one endpoint (specifically, when a user unflag's a node, the relation between the user and that node is deleted).
Thanks so much for the support.
Comment #16
acrazyanimal commentedI second the request for all the actions posted by Itangalo and found in #1260262: More Rules actions!.
Especially "4. Relation end points as tokens". I was just logging in to report this one as a bug since the endpoints token is made available, but doesn't seem to actually work at all. I assumed that I would at least be able to do a "data comparison" on the bundle type or a "Entity is of type" condition to reveal the
endpoints:0entity's properties like you can do on every other entity. I also thought that I might be able to check the types and pass the endpoints to a second rules component, but they don't validate that way as well. Alas, to my disappointment neither of these approaches work and I cannot imagine any other way of accessing the related entities' data. Should a new issue be opened for this or will it be covered by a solution here?cheers.
Comment #17
acrazyanimal commentedSeems the 'code' component was removed from the list so my last comment changed it to api. I think this is more suiting...
Comment #18
mikran commentedThe feature request in #1418646: API function to load endpoint entities might be somewhat related to this. If something similar gets added to the core it would be neat to have the option to load just one type of entities.
Comment #19
acrazyanimal commentedSee #1361796: rules: load related entities, entity fields unavailable for a patch to "Loads related entities".
Comment #20
naught101 commentedIs it just me, or is this issue extremely convoluted? Can someone following it please edit the original post and add a summary of WTF is going on? It might make more sense to split off separate requests into their own issues, so that they are easier to follow.
Re: the original post (delete A related to B when B is deleted), see #1715332: Delete endpoints together with source and #893750: Event: "Content is going to be deleted".
Comment #21
mikran commentedYes this is probably duplicate of #893750: Event: "Content is going to be deleted" or not applicable anymore as new load related functions have also been added since this issue was first opened.