You are here

public function ScheduledTransitionsListBuilder::buildRow in Scheduled Transitions 8

Same name and namespace in other branches
  1. 2.x src/ScheduledTransitionsListBuilder.php \Drupal\scheduled_transitions\ScheduledTransitionsListBuilder::buildRow()

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

src/ScheduledTransitionsListBuilder.php, line 84

Class

ScheduledTransitionsListBuilder
Scheduled transition list builder.

Namespace

Drupal\scheduled_transitions

Code

public function buildRow(EntityInterface $entity) : array {

  /** @var \Drupal\scheduled_transitions\Entity\ScheduledTransitionInterface $entity */
  $row = [];
  $hostEntity = $entity
    ->getEntity();
  try {
    $row['host_entity'] = $hostEntity ? $hostEntity
      ->toLink() : $this
      ->t('- Missing entity -');
  } catch (UndefinedLinkTemplateException $exception) {
    $row['host_entity'] = $hostEntity
      ->label();
  }

  // Date.
  $time = $entity
    ->getTransitionTime();
  $row['date'] = $this->dateFormatter
    ->format($time);
  return $row + parent::buildRow($entity);
}