You are here

public function AccessTokenListBuilder::buildRow in Access unpublished 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()

1 call to AccessTokenListBuilder::buildRow()
EntityFormAccessTokenListBuilder::buildRow in src/EntityFormAccessTokenListBuilder.php
Builds a row for an entity in the entity listing.
1 method overrides AccessTokenListBuilder::buildRow()
EntityFormAccessTokenListBuilder::buildRow in src/EntityFormAccessTokenListBuilder.php
Builds a row for an entity in the entity listing.

File

src/AccessTokenListBuilder.php, line 84

Class

AccessTokenListBuilder
Defines a class to build a listing of access token entities.

Namespace

Drupal\access_unpublished

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\access_unpublished\Entity\AccessToken $entity */
  $row['expire_date']['data'] = [
    '#plain_text' => $entity
      ->get('expire')->value > 0 ? $this->dateFormatter
      ->format($entity
      ->get('expire')->value, 'short') : $this
      ->t('Unlimited'),
  ];
  if ($entity
    ->isExpired()) {
    $row['expire_date']['data'] = [
      '#markup' => 'Expired token',
      '#prefix' => '<div class="access-unpublished-expired">',
      '#suffix' => '</div>',
    ];
  }
  $row['host']['data'] = [
    '#type' => 'link',
    '#title' => $entity
      ->getHost()
      ->label(),
    '#url' => $entity
      ->getHost()
      ->toUrl(),
  ];
  $row['operations']['data'] = $this
    ->buildOperations($entity);
  return $row + parent::buildRow($entity);
}