mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
Display enabled and disabled notifications in separate tables.
This commit is contained in:
parent
c4b312a1b9
commit
4ebfea8ef4
|
@ -10,6 +10,25 @@ use Drupal\Core\Entity\EntityInterface;
|
|||
*/
|
||||
class DataStreamNotificationListBuilder extends ConfigEntityListBuilder {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load() {
|
||||
$entities = [
|
||||
'enabled' => [],
|
||||
'disabled' => [],
|
||||
];
|
||||
foreach (parent::load() as $entity) {
|
||||
if ($entity->status()) {
|
||||
$entities['enabled'][] = $entity;
|
||||
}
|
||||
else {
|
||||
$entities['disabled'][] = $entity;
|
||||
}
|
||||
}
|
||||
return $entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -49,4 +68,38 @@ class DataStreamNotificationListBuilder extends ConfigEntityListBuilder {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render() {
|
||||
|
||||
$list['#type'] = 'container';
|
||||
|
||||
// Add markup for the enabled table.
|
||||
$list['enabled']['heading']['#markup'] = '<h2>' . $this->t('Enabled', [], ['context' => 'Plural']) . '</h2>';
|
||||
$list['enabled']['table']['#empty'] = $this->t('There are no enabled notifications.');
|
||||
|
||||
// Add markup for the disabled table.
|
||||
$list['disabled']['heading']['#markup'] = '<h2>' . $this->t('Disabled', [], ['context' => 'Plural']) . '</h2>';
|
||||
$list['disabled']['table']['#empty'] = $this->t('There are no disabled notifications.');
|
||||
|
||||
// Build separate tables for enabled and disabled.
|
||||
$entities = $this->load();
|
||||
foreach (['enabled', 'disabled'] as $status) {
|
||||
$list[$status]['table'] = [
|
||||
'#type' => 'table',
|
||||
'#header' => $this->buildHeader(),
|
||||
];
|
||||
|
||||
// Build a row for each entity.
|
||||
foreach ($entities[$status] as $entity) {
|
||||
if ($row = $this->buildRow($entity)) {
|
||||
$list[$status]['table']['#rows'][$entity->id()] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue