You are here

public function EckController::query in Entity Construction Kit (ECK) 7

Builds and executes the query for loading.

Return value

Traversable The results in a Traversable object.

Overrides EntityAPIController::query

File

./eck.module, line 380
ENTITY CONSTRUCTION KIT

Class

EckController
Base controller class for ECK entites.

Code

public function query($ids, $conditions, $revision_id = FALSE) {
  $result = parent::query($ids, $conditions, $revision_id);
  if (!empty($this->entityInfo['entity class']) && $result
    ->rowCount()) {
    $row = $result
      ->fetch(PDO::FETCH_ASSOC);

    // Allow to create custom per-bundle specific class implementations.
    $class_name = eck_get_class_name($row['type'], 'EntityType');
    if (drupal_autoload_class($class_name)) {
      $this->entityInfo['entity class'] = $class_name;
    }
    $result = parent::query($ids, $conditions, $revision_id);
  }
  return $result;
}