You are here

public function EntityDefaultUIController::overviewTable in Entity API 7

Generates the render array for a overview table for arbitrary entities matching the given conditions.

Parameters

$conditions: An array of conditions as needed by entity_load().

Return value

array A renderable array.

1 call to EntityDefaultUIController::overviewTable()
EntityDefaultUIController::overviewForm in includes/entity.ui.inc
Builds the entity overview form.

File

includes/entity.ui.inc, line 205
Provides a controller for building an entity overview form.

Class

EntityDefaultUIController
Default UI controller providing admin UI.

Code

public function overviewTable($conditions = array()) {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', $this->entityType);

  // Add all conditions to query.
  foreach ($conditions as $key => $value) {
    $query
      ->propertyCondition($key, $value);
  }
  if ($this->overviewPagerLimit) {
    $query
      ->pager($this->overviewPagerLimit);
  }
  $results = $query
    ->execute();
  $ids = isset($results[$this->entityType]) ? array_keys($results[$this->entityType]) : array();
  $entities = $ids ? entity_load($this->entityType, $ids) : array();
  ksort($entities);
  $rows = array();
  foreach ($entities as $entity) {
    $rows[] = $this
      ->overviewTableRow($conditions, entity_id($this->entityType, $entity), $entity);
  }
  $render = array(
    '#theme' => 'table',
    '#header' => $this
      ->overviewTableHeaders($conditions, $rows),
    '#rows' => $rows,
    '#empty' => t('None.'),
  );
  return $render;
}