MailingListListBuilder.php in Mailing List 8
File
src/MailingListListBuilder.php
View source
<?php
namespace Drupal\mailing_list;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Url;
use Drupal\Core\Entity\EntityInterface;
class MailingListListBuilder extends ConfigEntityListBuilder {
public function buildHeader() {
$header['title'] = t('Name');
$header['description'] = [
'data' => t('Description'),
'class' => [
RESPONSIVE_PRIORITY_MEDIUM,
],
];
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row = [];
$row['label'] = [
'data' => $entity
->label(),
'class' => [
'menu-label',
],
];
$row['description']['data'] = [
'#markup' => $entity
->getDescription(),
];
return $row + parent::buildRow($entity);
}
public function getOperations(EntityInterface $entity) {
$operations = parent::getOperations($entity);
$operations['export'] = [
'title' => $this
->t('Export e-mail addresses'),
'url' => Url::fromRoute('entity.mailing_list.export', [
'mailing_list' => $entity
->id(),
]),
];
$operations['import'] = [
'title' => $this
->t('Import e-mail addresses'),
'url' => Url::fromRoute('entity.mailing_list.import', [
'mailing_list' => $entity
->id(),
]),
];
return $operations;
}
public function render() {
$build = parent::render();
$build['table']['#empty'] = $this
->t('No mailing lists available. <a href=":link">Add mailing list</a>.', [
':link' => Url::fromRoute('mailing_list.list_add')
->toString(),
]);
return $build;
}
}