public function GDPRTaskUIController::overviewTable in General Data Protection Regulation 7
Generates the render array for a overview tables for different statuses.
Overrides EntityDefaultUIController::overviewTable
File
- modules/
gdpr_tasks/ src/ Entity/ GDPRTaskUIController.php, line 35
Class
- GDPRTaskUIController
- The Task type entity controller class.
Code
public function overviewTable($conditions = array()) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', $this->entityType);
$query
->propertyOrderBy('created');
// 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);
// Always show at least requested and complete tables.
$rows = array(
'requested' => array(),
'closed' => array(),
);
foreach ($entities as $entity) {
$rows[$entity->status][] = $this
->overviewTableRow($conditions, entity_id($this->entityType, $entity), $entity);
}
$render = array();
foreach ($rows as $status => $status_rows) {
$render[$status] = array(
'#theme' => 'table',
'#header' => $this
->overviewTableHeaders($conditions, $status_rows),
'#rows' => $status_rows,
'#caption' => t('Tasks with status - @status', array(
'@status' => ucfirst($status),
)),
'#empty' => t('No tasks.'),
'#weight' => 3,
);
// @todo Find a better way to order statuses.
if ($status == 'requested') {
$render[$status]['#weight'] = 0;
}
}
return $render;
}