You are here

public function AccessTokenListBuilder::buildRow in Simple OAuth (OAuth2) & OpenID Connect 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/AccessTokenListBuilder.php, line 34

Class

AccessTokenListBuilder
Defines a class to build a listing of Access Token entities.

Namespace

Drupal\simple_oauth

Code

public function buildRow(EntityInterface $entity) {

  /* @var $entity \Drupal\simple_oauth\Entity\AccessToken */
  $type = $entity
    ->get('resource')->target_id == 'authentication' ? t('Refresh Token') : t('Access Token');
  $row['type'] = $type;
  $user = $entity
    ->get('auth_user_id')->entity;
  $row['user'] = $this
    ->l($user
    ->label(), new Url('entity.user.canonical', array(
    'user' => $user
      ->id(),
  )));
  $owner = $entity
    ->get('user_id')->entity;
  $row['owner'] = $this
    ->l($owner
    ->label(), new Url('entity.user.canonical', array(
    'user' => $owner
      ->id(),
  )));
  $row['id'] = $entity
    ->id();
  $row['name'] = $this
    ->l($entity
    ->label(), new Url('entity.access_token.edit_form', array(
    'access_token' => $entity
      ->id(),
  )));
  $row['resource'] = $entity
    ->get('resource')->entity
    ->label();
  return $row + parent::buildRow($entity);
}