Ok, after some discussion with sun, I'm wrapping my head around this slowly. There may be mistakes in what I write here:
So, what we have is a system for creating basic relationships between entities. What we need is a way for users to create arbitrary bundles that have at least a predicate/name, and a specified set of possible object/target entity types(1). Next we need a UI for adding fields to those bundles(2).
We don't really need to worry about n->1 relationships, as they are covered by Field API -- just duplicate the field on what ever entity you want as a subject/source.
A couple of points for discussion:
- Is there any reason to limit the possibilities for subject/object in the module, or is it fine to leave all options open to the user (could they break anything?)
- Should the settings for the predicate and object set be in the field settings, or in the field instance settings? I don't know enough about this yet, but might there be trouble with things like views if we go with field instance settings, and the field is re-used on different entities with different settings?
- What for a UI? Should we code our own, or should we use entity.module?
What have I missed?
(1) This covers #963360: UI for limited references of specific entity types
(2) This covers #948946: N-ary relationships?
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | relation-HEAD.bundle.12.patch | 2.79 KB | sun |
| #11 | relation-HEAD.bundle.10.patch | 2.98 KB | sun |
| #9 | relation-HEAD.bundle.9.patch | 1.99 KB | sun |
| #8 | relation.gif | 7.49 KB | sun |
| #4 | relation-HEAD.entity-bundle.4.patch | 1.58 KB | sun |
Comments
Comment #1
naught101 commentedAlso, I'm not entirely sure how this works with the
$entities['relation']['bundle']array inrelation_entity_info(). Is there another way of making drupal aware that these custom bundles belong to the relationship entity?Comment #2
sunThe 'bundles' key is normally populated dynamically. For example, see end of http://api.drupal.org/api/drupal/modules--node--node.module/function/nod...
Comment #3
sunRequires the patch in #981990: Fall back for entities that don't explicitly define an access callback for Entity API
Comment #4
sunAdditionally taking the WTF in #977380: Entity bundles as entities is confusing into account.
Comment #5
naught101 commentedSo, looks like we're gonna need a 'relation_type' table similar to the node_type table.
How's this for a minimum set of requirements?
I figure everything else can just be a field. If the predicate isn't always necessary, it could probably be a field too.
I wonder if RDF linkage (namespaces etc.) would require anything, or would that just be done with another field and in the formatter? I guess that depends on how integrated we want this to be with RDF
(see #981150: Tie to RDF module integration hooks?)
Comment #6
chx commentedWe use an example of company donates to a party and user donates to a party.
Finally, we are aware that this needs to be per bundle and not per entity type but there is no bundle registry so we punt on that.
Comment #7
dmitrig01 commentedyou could (potentially) have trinary relationships too, just can't think of any that aren't better represented by 2 binary relationships :-P
Comment #8
sunComment #9
sunUpdated to be based on fields instead.
Comment #10
naught101 commented@dmitrig01: #948946: N-ary relationships? :D
Comment #11
sunFields being relation entity bundles + Entity UI integration.
Comment #12
sunAlright, more like this. Not sure why Entity API isn't taking over the relation_type entity loading.
Comment #13
chx commentedI am neither getting your drawing nor your code. Why did we gain a new relation_type entity? Which is not fieldable? What's going on? I do not get this. We want fields on the relations themselves, ie. that's our fieldable entity type. What's this relation_type? What purpose does it serve?
Edit: using companies, users and parties help a lot in explaining I think :) So we have a relation type field with a field_name of donation attached to the company, the user and the party entity types. We have an "amount" integer field attached to the bundle called donation and the entity type is relation. Do not see the need for relation_type anywhere.
Comment #15
sunPostponing this issue for now. Actually, it probably won't fix due to our conclusions of today: http://drupal.org/node/981364#comment-3778106
But anyway, not 100% confident with closing this down yet (due to fieldable fields modules confusion), so keeping it open/postponed for now.
Comment #16
Shadlington commentedTagging
Comment #17
naught101 commentedbundle creation has been rebooted. #1113654: Relation reboot