You are here

public function ServerListBuilder::buildRow in OAuth2 Server 2.0.x

Same name and namespace in other branches
  1. 8 src/ServerListBuilder.php \Drupal\oauth2_server\ServerListBuilder::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()

1 call to ServerListBuilder::buildRow()
ServerListBuilder::render in src/ServerListBuilder.php
Builds the entity listing as renderable array for table.html.twig.

File

src/ServerListBuilder.php, line 55

Class

ServerListBuilder
Builds a listing of oauth2 server entities.

Namespace

Drupal\oauth2_server

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
  $row = parent::buildRow($entity);
  $status_label = $entity
    ->status() ? $this
    ->t('Enabled') : $this
    ->t('Disabled');
  $status_icon = [
    '#theme' => 'image',
    '#uri' => $entity
      ->status() ? 'core/misc/icons/73b355/check.svg' : 'core/misc/icons/ea2800/error.svg',
    '#width' => 18,
    '#height' => 18,
    '#alt' => $status_label,
    '#title' => $status_label,
  ];
  return [
    'data' => [
      'label' => [
        'data' => $entity
          ->label(),
        'class' => [
          'oauth2-server-name',
        ],
      ],
      'status' => [
        'data' => $status_icon,
        'class' => [
          'checkbox',
        ],
      ],
      'operations' => $row['operations'],
    ],
    'title' => $this
      ->t('ID: @name', [
      '@name' => $entity
        ->id(),
    ]),
    'class' => [
      Html::cleanCssIdentifier($entity
        ->getEntityTypeId() . '-' . $entity
        ->id()),
      $entity
        ->status() ? 'oauth2-server-list-enabled' : 'oauth2-server-list-disabled',
    ],
  ];
}