Problem/Motivation
Base fields of type primary_entity_reference are missing views support for views relationships and boolean handlers.
This is the underlying cause of CRM's issue #3566240: Views relationship plugin to relate a Contact to its Relationships.
Steps to reproduce
- Add a base field definition for a Primary Entity Reference field for an entity type
- Create a view of entities of that type
- Attempt to add a views relationship to the view for the field added earlier
- Observe that no relevant relationships are offered as options
Proposed resolution
Add views relationships and boolean handlers for base fields of type primary_entity_reference.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork primary_entity_reference-3576123
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
jdleonardAdded the needed Views support and performed basic manual testing via Views UI.
Comment #4
jdleonardNeeds a few phpDoc comments and to investigate one test failure for phpunit (next minor):
I won't have time to look into this further for a while.
Comment #5
jdleonardComment #6
jdleonardTests are now passing.
Note: had to remove "next major" from CI and opened #3585085: Drupal 12 support
I intend to review this further, but in the meantime it could do with some additional review.
Comment #7
sikofitt@jdleonard Just ran through the steps and if I am understanding correctly the views integration is working for me. I am able to add relationships and filter by them.
Comment #8
jdleonard@sikofitt Did you definitely add a base field definition (as opposed to a configurable field definition)? E.g. using
baseFieldDefinitions()?You might also double check #3566240: Views relationship plugin to relate a Contact to its Relationships.
Comment #9
sikofitt@jdleonard, I didn't do anything programmatically. I just added a plain text field and then created the view. Does this need to be tested by creating a test baseFieldDefinitions() in code?
Comment #10
jdleonard@sikofitt exactly!
Comment #11
jdleonardYou could also test by creating a view of CRM contacts and attempting to add a views relationship to contacts' contact methods (emails, telephones, addresses) as those fields are defined in
Contact::baseFieldDefinitions().