SitewideAlertListBuilder.php in Sitewide Alert 8
File
src/SitewideAlertListBuilder.php
View source
<?php
namespace Drupal\sitewide_alert;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Link;
class SitewideAlertListBuilder extends EntityListBuilder {
public function buildHeader() {
$header['name'] = $this
->t('Name');
$header['style'] = $this
->t('Style');
$header['active'] = $this
->t('Active');
$header['scheduled'] = $this
->t('Scheduled');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['name'] = Link::createFromRoute($entity
->label(), 'entity.sitewide_alert.edit_form', [
'sitewide_alert' => $entity
->id(),
]);
$row['style'] = AlertStyleProvider::alertStyleName($entity
->getStyle());
$row['active'] = $entity
->isPublished() ? '✔' : '✘';
$row['scheduled'] = $entity
->isScheduled() ? '✔' : '✘';
return $row + parent::buildRow($entity);
}
}