You are here

public function CerUIController::overviewTable in Corresponding Entity References 7.3

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.

Overrides EntityDefaultUIController::overviewTable

File

includes/CerUIController.inc, line 87

Class

CerUIController
Contains the controller class for CER's UI (i.e., preset management pages), used by Entity API.

Code

public function overviewTable($conditions = array()) {
  $render = array(
    '#header' => array(
      t('Left Field'),
      t('Right Field'),
      t('Status'),
      t('Enabled'),
      t('Bidirectional'),
      t('Weight'),
      t('Operations'),
    ),
    '#tabledrag' => array(
      array(
        'action' => 'order',
        'relationship' => 'sibling',
        'group' => 'cer-weight',
      ),
    ),
    '#empty' => t('None.'),
    '#type' => 'table',
  );
  $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);
  }
  $query
    ->fieldOrderBy('cer_weight', 'value');
  $results = $query
    ->execute();
  $entities = isset($results['cer']) ? entity_load('cer', array_keys($results['cer'])) : array();
  foreach ($entities as $entity) {
    $render[$entity->pid] = $this
      ->overviewTableRow($conditions, $entity->pid, $entity);
  }
  return $render;
}