Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'd like to make http://drupal.org/project/reference_option_limit respect the sort options set in an entity reference field's settings. It would be handy for my module to be able to do this:
$handler = entityreference_get_handler($field_option_limited);
$query = $handler->buildEntityFieldQuery();
... and then add its own conditions to the query.
The method is protected in the base class -- though it's public in the subclasses.
Comment | File | Size | Author |
---|---|---|---|
#2 | 1391376.entityreference.make-buildEntityFieldQuery-public.patch | 2.07 KB | joachim |
Comments
Comment #1
joachim CreditAttribution: joachim commentedComment #2
joachim CreditAttribution: joachim commentedComment #3
joachim CreditAttribution: joachim commentedThough EntityReference_SelectionHandler_Views doesn't have this at all.
So this needs a rethink.
Comment #4
Damien Tournoud CreditAttribution: Damien Tournoud commentedEntityReference_SelectionHandler_Generic::buildEntityFieldQuery()
is strictly protected. It is useful for child classes of the base selection handler, but that's it.I think for both use cases you want
EntityReference_SelectionHandler::getReferencableEntities()
and go from here (sub-filter, or use the IDs that you get to load the entities).Comment #5
joachim CreditAttribution: joachim commentedAgreed.
Comment #6
joachim CreditAttribution: joachim commentedHmm actually on second thoughts, I'm going to reopen this.
My patch was wrong: it doesn't belong in the interface as the Views selection handler doesn't need one at all.
However, there's still the matter that I could really do with being able to use this in reference_option_limit. This being private means I have to duplicate a big chunk of code.