You are here

public function MessageListBuilder::buildRow in Message 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

src/MessageListBuilder.php, line 87

Class

MessageListBuilder
Defines a class to build a listing of Message entities.

Namespace

Drupal\message

Code

public function buildRow(EntityInterface $entity) {

  /** @var Message $entity */
  $text = $entity
    ->getText();
  return [
    'changed' => $this->dateService
      ->format($entity
      ->getCreatedTime(), 'short'),
    'text' => [
      'data' => [
        '#markup' => reset($text),
      ],
    ],
    'template' => $entity
      ->getTemplate()
      ->label(),
    'author' => !empty($entity
      ->getOwner()) ? $entity
      ->getOwner()
      ->label() : $this
      ->t('Anonymous'),
  ];
}