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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Title: make buildEntityFieldQuery() public rather than protected » make buildEntityFieldQuery() public rather than protected; add to interface
joachim’s picture

Status: Active » Needs review
FileSize
2.07 KB
joachim’s picture

Status: Needs review » Needs work

Though EntityReference_SelectionHandler_Views doesn't have this at all.

So this needs a rethink.

Damien Tournoud’s picture

Status: Needs work » Closed (won't fix)

EntityReference_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).

joachim’s picture

Agreed.

joachim’s picture

Title: make buildEntityFieldQuery() public rather than protected; add to interface » make buildEntityFieldQuery() public rather than protected so other modules can use it
Status: Closed (won't fix) » Active

Hmm 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.