You are here

public function HttpClientManagerPreview::view in HTTP Client Manager 8.2

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

View.

Return value

array The render array to be used as output.

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'),
    'parent' => $this
      ->t('Parent'),
    'base_uri' => $this
      ->t('Base URI'),
    'operations' => $this
      ->t('Operations'),
  ];
  $rows = [];
  foreach ($servicesApi as $api) {
    $rows[] = [
      'id' => $api['id'],
      'title' => $api['title'],
      'parent' => !empty($api['parent_title']) ? $api['parent_title'] : NULL,
      'base_uri' => $api['config']['base_uri'],
      'operations' => [
        'data' => $this
          ->buildOperations($api),
      ],
    ];
  }
  return [
    '#type' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => $this
      ->t('There are no Http Services Api configured yet.'),
  ];
}