You are here

public function ApiTokenController::adminOverview in API Tokens 8

Same name and namespace in other branches
  1. 8.2 src/Controller/ApiTokenController.php \Drupal\api_tokens\Controller\ApiTokenController::adminOverview()

Displays the API tokens overview page.

Return value

array A renderable array.

1 string reference to 'ApiTokenController::adminOverview'
api_tokens.routing.yml in ./api_tokens.routing.yml
api_tokens.routing.yml

File

src/Controller/ApiTokenController.php, line 46

Class

ApiTokenController
Controller routines for API tokens routes.

Namespace

Drupal\api_tokens\Controller

Code

public function adminOverview() {
  $build['table'] = [
    '#type' => 'table',
    '#header' => [
      $this
        ->t('Token'),
      $this
        ->t('Synopsis'),
      $this
        ->t('Provider'),
    ],
    '#empty' => $this
      ->t('There are no API tokens registered.'),
  ];
  foreach ($this->apiTokenManager
    ->getSortedDefinitions() as $id => $definition) {
    $row =& $build['table'][$id];
    $row['token'] = [
      '#type' => 'item',
      '#title' => $definition['label'],
      '#description' => $definition['description'],
      '#description_display' => 'after',
    ];
    $row['synopsis'] = $this
      ->buildSynopsis($id);
    $row['provider'] = [
      '#type' => 'item',
      '#title' => $definition['category'],
      '#description' => $this
        ->t('Machine name: @provider', [
        '@provider' => $definition['provider'],
      ]),
      '#description_display' => 'after',
    ];
  }
  return $build;
}