CalendarEventTypeListBuilder.php in Opigno calendar event 3.x
File
src/CalendarEventTypeListBuilder.php
View source
<?php
namespace Drupal\opigno_calendar_event;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Url;
use Drupal\Core\Entity\EntityInterface;
class CalendarEventTypeListBuilder extends ConfigEntityListBuilder {
public function buildHeader() {
$header['title'] = t('Label');
$header['description'] = [
'data' => t('Description'),
'class' => [
RESPONSIVE_PRIORITY_MEDIUM,
],
];
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['title'] = [
'data' => $entity
->label(),
'class' => [
'menu-label',
],
];
$row['description']['data'] = [
'#markup' => $entity
->get('description'),
];
return $row + parent::buildRow($entity);
}
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
if (isset($operations['edit'])) {
$operations['edit']['weight'] = 30;
}
return $operations;
}
public function render() {
$build = parent::render();
$build['table']['#empty'] = $this
->t('No calendar event types available. <a href=":link">Add event type</a>.', [
':link' => Url::fromRoute('entity.opigno_calendar_event_type.add_form')
->toString(),
]);
return $build;
}
}