KanbanLogListBuilder.php in Content Planner 8
File
modules/content_kanban/src/KanbanLogListBuilder.php
View source
<?php
namespace Drupal\content_kanban;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Link;
class KanbanLogListBuilder extends EntityListBuilder {
public function load() {
$query = \Drupal::entityQuery('content_kanban_log');
$query
->sort('created', 'DESC');
$result = $query
->execute();
return $this->storage
->loadMultiple($result);
}
public function buildHeader() {
$header['id'] = $this
->t('Kanban Log ID');
$header['name'] = $this
->t('Name');
$header['workflow'] = $this
->t('Workflow');
$header['entity'] = $this
->t('Entity / Entity ID');
$header['state_from'] = $this
->t('State from');
$header['state_to'] = $this
->t('State to');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['id'] = $entity
->id();
$row['name'] = $entity
->label();
if ($workflow = $entity
->getWorkflow()) {
$row['workflow'] = $workflow
->label();
}
else {
$row['workflow'] = t('Workflow with ID @id does not exist anymore', [
'@id' => $entity
->getWorkflowId(),
]);
}
if ($logEntity = $entity
->getEntityObject()) {
$row['entity'] = new Link($logEntity
->label(), $logEntity
->toUrl());
}
else {
$row['entity'] = t('Entity @entity_type with ID @id does not exist anymore', [
'@id' => $entity
->getEntityId(),
'@entity_type' => $entity
->getType(),
]);
}
$row['state_from'] = $entity
->getStateFrom();
$row['state_to'] = $entity
->getStateTo();
return $row + parent::buildRow($entity);
}
}