Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
In #1801726: EntityFieldQuery v2 AddMetaData() was removed from EFQ.
In #1801304: Add Entity reference field we need to be able to add the Selection handler to the EFQ object, as later on in hook_query_TAG_alter() we want to let the Selection handler alter the sqlQuery
for entity-access:
/**
* Implements hook_query_TAG_alter().
*/
function entity_reference_query_entity_reference_alter(AlterableInterface $query) {
$handler = $query->getMetadata('entity_reference_selection_handler');
$handler->entityFieldQueryAlter($query);
}
Here's a gist with a clearer flow.
chx via IRC asked to file an issue.
Comment | File | Size | Author |
---|---|---|---|
#8 | 1828408-efq-tag-7.patch | 5.13 KB | amitaibu |
#8 | interdiff-7.txt | 1.96 KB | amitaibu |
#6 | 1828408-efq-tag-6.patch | 5.09 KB | amitaibu |
#6 | interdiff.txt | 2.68 KB | amitaibu |
#4 | 1828408-efq-tag-4.patch | 3.11 KB | amitaibu |
Comments
Comment #1
amitaibuBetter title, to indicate addTag() is also required as we want to act only on "entity_reference" related queries.
Comment #2
chx CreditAttribution: chx commentedI hoped you will actually file a patch :) I will see what i can do.
Comment #3
amitaibuVery naive implementation. addMetadata seems to work, but addTag() not. Gonna dive a bit more into the code..
Comment #4
amitaibuAm I in the right direction? :)
Comment #5
chx CreditAttribution: chx commentedThat looks quite good. It seems you are not adding metadata yet, it seems. And, do you think you could write a test for this? Perhaps flip a global in a field_test hook (because that module is already on) ?
Comment #6
amitaibu> do you think you could write a test for this?
Of course, that was the plan :) Patch with test.
Comment #7
Fabianx CreditAttribution: Fabianx commentedLooks really good. Easy to see, test is good as well, works, same implementation as Select.php. => RTBC
One doc nitpick:
core/lib/Drupal/Core/Database/Query/Select.php has:
instead of:
for each of those. I think it is nicer to know this is the implementation of the AlterableInterface than of the QueryInterface and it should be consistent.
Comment #8
amitaibuAddressing #7 -- @Fabianx, that's what you meant, right?
Comment #10
amitaibuComment #11
chx CreditAttribution: chx commentedSeems good.
Comment #12
Fabianx CreditAttribution: Fabianx commentedYup, #8: That was what I meant.
+1 for RTBC
Comment #13
webchickCommitted and pushed to 8.x. Thanks!