You are here

public function ConflictListBuilder::buildRow in Workspace 8

Build a row for the given entity.

@todo Handle translations.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to build the render array row for.

Return value

array A row render array used by a table render array.

See also

\Drupal\node\NodeListBuilder::buildRow

1 call to ConflictListBuilder::buildRow()
ConflictListBuilder::buildList in src/Controller/Component/ConflictListBuilder.php
Build the render array to display on the page.

File

src/Controller/Component/ConflictListBuilder.php, line 130

Class

ConflictListBuilder
A list builder for entity revision conflicts.

Namespace

Drupal\workspace\Controller\Component

Code

public function buildRow(EntityInterface $entity) {
  $entity_type = $entity
    ->getEntityType();
  $row['title'] = $entity
    ->label();

  // @todo Is there a way to get the human readable name for the bundle?
  $row['type'] = $entity
    ->bundle();
  $uid_key = $entity_type
    ->getKey('uid');
  if ($uid_key) {
    $row['author']['data'] = [
      '#theme' => 'username',
      '#account' => $entity
        ->get($uid_key)->entity,
    ];
  }
  else {
    $row['author'] = $this
      ->t('None');
  }
  $status_key = $entity_type
    ->getKey('status');
  if ($status_key) {
    $row['status'] = $entity
      ->get($status_key)->value ? $this
      ->t('published') : $this
      ->t('not published');
  }
  else {
    $row['status'] = $this
      ->t('published');
  }

  // @todo Is there an entity key for changed time?
  if (method_exists($entity, 'getChangedTime')) {
    $row['changed'] = $this->dateFormatter
      ->format($entity
      ->getChangedTime(), 'short');
  }
  return $row;
}