You are here

protected function EntityAPIControllerExportable::buildQuery in Entity API 7

Support loading by name key.

Overrides EntityAPIController::buildQuery

File

includes/entity.controller.inc, line 717
Provides a controller building upon the core controller but providing more features like full CRUD functionality.

Class

EntityAPIControllerExportable
A controller implementing exportables stored in the database.

Code

protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {

  // Add the id condition ourself, as we might have a separate name key.
  $query = parent::buildQuery(array(), $conditions, $revision_id);
  if ($ids) {

    // Support loading by numeric ids as well as by machine names.
    $key = is_numeric(reset($ids)) ? $this->idKey : $this->nameKey;
    $query
      ->condition("base.{$key}", $ids, 'IN');
  }
  return $query;
}