I have several custom content entity types that have relationships to each another. The fields used are defined as base fields and I am using
$fields['FIELD_NAME'] = BaseFieldDefinition::create('entity_reference').
Views doesn't currently implement reverse relationships for base fields, which is a feature request.
I need to define the relationship in the module with
Using the examples provided, I was able to define a reverse relationship for an entity reference field with cardinality of 1 (where the field is created in the entity's base_table), but I can't figure out how to do it when the cardinality is higher than 1, or unlimited (where the field is created in a separate table).
None of the examples on the documentation pages (or that I have been able to find googling) defines a relationship between two entities that requires an intermediary table.
Views defines an
EntityReverse class that I have looked at for ideas. It has a
$first_join and a
$second_join. I can confirm that if the field is added to the entity using the normal UI, then the view provides both relationships, to the related entity and the reverse relationship from the related entity.
I am not sure at all how to translate the
EntityReverse class into a definition I could pass to
And How to do a Reverse Entity Reference? is not the answer.
Does anyone know a solution?