You are here

public function KanbanLogListBuilder::buildRow in Content Planner 8

Builds a row for an entity in the entity listing.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.

Return value

array A render array structure of fields for this entity.

Overrides EntityListBuilder::buildRow

See also

\Drupal\Core\Entity\EntityListBuilder::render()

File

modules/content_kanban/src/KanbanLogListBuilder.php, line 49

Class

KanbanLogListBuilder
Defines a class to build a listing of Kanban Log entities.

Namespace

Drupal\content_kanban

Code

public function buildRow(EntityInterface $entity) {

  /* @var $entity \Drupal\content_kanban\Entity\KanbanLog */
  $row['id'] = $entity
    ->id();
  $row['name'] = $entity
    ->label();

  // Workflow.
  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);
}