You are here

public function HttpClientManagerPreview::view in HTTP Client Manager 8

Same name and namespace in other branches
  1. 8.2 src/Controller/HttpClientManagerPreview.php \Drupal\http_client_manager\Controller\HttpClientManagerPreview::view()

View.

Return value

string Return Hello string.

1 string reference to 'HttpClientManagerPreview::view'
http_client_manager.routing.yml in ./http_client_manager.routing.yml
http_client_manager.routing.yml

File

src/Controller/HttpClientManagerPreview.php, line 46

Class

HttpClientManagerPreview
Class HttpClientManagerPreview.

Namespace

Drupal\http_client_manager\Controller

Code

public function view() {
  $servicesApi = $this->httpServicesApi
    ->getServicesApi();
  $header = [
    'id' => $this
      ->t('ID'),
    'title' => $this
      ->t('Title'),
    'base_url' => $this
      ->t('Base URL'),
    'operations' => $this
      ->t('Operations'),
  ];
  $rows = [];
  foreach ($servicesApi as $api) {
    $row = array_intersect_key($api, $header);
    $row['operations']['data'] = $this
      ->buildOperations($api);
    $rows[] = $row;
  }
  return [
    '#type' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => $this
      ->t('There are no Http Services Api configured yet.'),
  ];
}