DRUPAL CONTRIB MODULE: COMPOSITE REFERENCE
Today I want to introduce a new contrib module called Composite Reference. Why is it called this way? Because it is intended to be used to strengthen the "link" between entities that are meant to live and die together.
In many cases, we use entity references to entities that are not reusable (or not meant to be entities). They are simply more complex storage vehicles for data that belongs to another entity (for the sake of explanation, we can call this the parent). So when the parent is removed, it is logical that the referenced entity (the child) is also removed because it is not supposed to exist outside the context of its parent. And this is a type of composite relationship: the two belong together as a unit. Of course, not all parent-child relationships are or have to be compound. But some can and I simply used them as an example.
So what does the module do? Aside from the fancy name, it does nothing more than making an entity reference field (or entity reference revisions) configurable to become composite. And when the relationship is compounded, the referenced entity is removed when the reference is removed. And to avoid all kinds of chaos and misuse, deletion is avoided if the referenced entity is referenced by another entity (by definition, NOT composite). However, this should not happen, as it would mark relationships as composite only in cases where the referenced entities are not reusable.
And that's pretty much it. You can read the README file for more information on how to use the module.
It is a module that I have found interesting and is quite useful for projects with very complex data structures and not very persistent data.
This project was written and is maintained as part of the OpenEuropa Initiative of the European Commission.
Have Any Project in Mind?
If you want to do something in Drupal maybe you can hire me.
Either for consulting, development or maintenance of Drupal websites.