my 2 cents on what would make this module very, very useful...

while bi-directional referencing certainly has value, so would providing the option to allow syncing of any number of entityreference fields, making this module much more generic and therefore useful, with the following:

1. add entityreference field sync settings, when instantiated in an entity, would look something like:

array(
'type' => $type, //true==in_array($type, array('egalitarian', 'double_link', 'master', 'slave'))
'sync_uuid' => $uuid, // $uuid==uuid_generate()
)

2. add to _insert, _update hooks, a check for this non-empty settings array. not sure what the best hooks or hook_module_implements_alter should be, because it depends on what other hook implementations are doing with the sync values.

3. if non-empty, find all other entities with entityreference settings array('sync_uuid' => $uuid) value and update (sync) their entityreference field values if different than the new value.

4. how the sync is implemented should depend on the sync type. a couple examples:

'double_link': what the module currently does - simplifies entity graph traversal.
'egalitarian': any entity can set the value for all others with the same sync_uuid.
'master': only the entity of this type can update all other entities with the same sync_uuid.
'slave': gets updated value of the master.

although the master-slave configuration purpose might seem similar to implementing another entityreference field (slaves pointing to master), implementing as field settings value might be faster and seems more sensible. this would be useful when a bundle has several entityreference fields, each referring to the same target type, but each with a different handler. prime example is with og 7.x-2.x, which deprecates groups entity for entityreference (which demonstrates unnecessary redundancy of all these reference types, but that's another thread altogether).

egalitarian use case is similar to master-slave condition (multiple entityreferences), but where no handler (module that created the field instance) has priority over others.

Comments

jm.federico’s picture

Hello

@jaypark
Thanks for the suggestion, it does seem like it can be very useful.
If you have the time, your are more than welcome to help!

If there is someone interested are able to help, it will be very much appreciated.

Cheers