class GDPRTaskUIController in General Data Protection Regulation 7
The Task type entity controller class.
Hierarchy
- class \EntityDefaultUIController
- class \EntityContentUIController
- class \EntityBundleableUIController
- class \GDPRTaskUIController
- class \EntityBundleableUIController
- class \EntityContentUIController
Expanded class hierarchy of GDPRTaskUIController
1 string reference to 'GDPRTaskUIController'
- gdpr_tasks_entity_info in modules/
gdpr_tasks/ gdpr_tasks.module - Implements hook_entity_info().
File
- modules/
gdpr_tasks/ src/ Entity/ GDPRTaskUIController.php, line 6
View source
class GDPRTaskUIController extends EntityBundleableUIController {
/**
* {@inheritdoc}
*/
public function hook_menu() {
$items = parent::hook_menu();
// Set this on the object so classes that extend hook_menu() can use it.
$plural_label = isset($this->entityInfo['plural label']) ? $this->entityInfo['plural label'] : $this->entityInfo['label'] . 's';
$items['admin/config/gdpr/task-list'] = array(
'title' => $plural_label,
'page callback' => 'drupal_get_form',
'page arguments' => array(
$this->entityType . '_overview_form',
$this->entityType,
),
'description' => 'Manage ' . $plural_label . '.',
'access callback' => 'entity_access',
'access arguments' => array(
'view',
$this->entityType,
),
'file' => 'includes/entity.ui.inc',
'weight' => 10,
);
return $items;
}
/**
* Generates the render array for a overview tables for different statuses.
*
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
protected function overviewTableHeaders($conditions, $rows, $additional_header = array()) {
$additional_header = array(
t('Type'),
t('Status'),
t('User'),
t('Requested'),
);
return parent::overviewTableHeaders($conditions, $rows, $additional_header);
}
/**
* {@inheritdoc}
*/
protected function overviewTableRow($conditions, $id, $entity, $additional_cols = array()) {
/* @var GDPRTask $entity */
$time_diff = REQUEST_TIME - $entity->created;
$created_ago = t('%time ago', array(
'%time' => format_interval($time_diff, 1),
));
$additional_cols = array(
$entity
->bundleLabel(),
$entity->status,
theme('username', array(
'account' => user_load($entity->user_id),
)),
format_date($entity->created, 'short') . ' - ' . $created_ago,
);
$row = parent::overviewTableRow($conditions, $id, $entity, $additional_cols);
// @todo Fix hardcoded links.
$row[0] = l($entity
->label(), $this->path . '/' . $id . '/view', array(
'query' => drupal_get_destination(),
));
$row[5] = l(t('edit'), $this->path . '/' . $id . '/edit', array(
'query' => drupal_get_destination(),
));
$row[6] = l(t('delete'), $this->path . '/' . $id . '/delete', array(
'query' => drupal_get_destination(),
));
return $row;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityContentUIController:: |
public | function |
Operation form submit callback. Overrides EntityDefaultUIController:: |
|
EntityDefaultUIController:: |
protected | property | ||
EntityDefaultUIController:: |
protected | property | ||
EntityDefaultUIController:: |
protected | property | ||
EntityDefaultUIController:: |
public | property | Defines the number of entries to show per page in overview table. | |
EntityDefaultUIController:: |
public | function | Applies an operation to the given entity. | |
EntityDefaultUIController:: |
public | function | Entity submit builder invoked via entity_ui_form_submit_build_entity(). | |
EntityDefaultUIController:: |
public | function | Provides definitions for implementing hook_forms(). | |
EntityDefaultUIController:: |
protected | function | Returns the operation count for calculating colspans. | |
EntityDefaultUIController:: |
public | function | Builds the operation form. | |
EntityDefaultUIController:: |
public | function | Operation form validation callback. | |
EntityDefaultUIController:: |
public | function | Builds the entity overview form. | |
EntityDefaultUIController:: |
public | function | Overview form submit callback. | |
EntityDefaultUIController:: |
public | function | Overview form validation callback. | |
EntityDefaultUIController:: |
public | function | ||
GDPRTaskUIController:: |
public | function |
Provides definitions for implementing hook_menu(). Overrides EntityBundleableUIController:: |
|
GDPRTaskUIController:: |
public | function |
Generates the render array for a overview tables for different statuses. Overrides EntityDefaultUIController:: |
|
GDPRTaskUIController:: |
protected | function |
Generates the table headers for the overview table. Overrides EntityDefaultUIController:: |
|
GDPRTaskUIController:: |
protected | function |
Generates the row for the passed entity and may be overridden in order to
customize the rows. Overrides EntityDefaultUIController:: |