You are here

public function ServiceEndpointResources::displayList in Services 9.0.x

Same name and namespace in other branches
  1. 8.4 src/Controller/ServiceEndpointResources.php \Drupal\services\Controller\ServiceEndpointResources::displayList()

List service resources.

Parameters

\Drupal\services\ServiceEndpointInterface|null $service_endpoint: A service endpoint entity.

Return value

array An renderable array.

1 string reference to 'ServiceEndpointResources::displayList'
services.routing.yml in ./services.routing.yml
services.routing.yml

File

src/Controller/ServiceEndpointResources.php, line 49

Class

ServiceEndpointResources
Class \Drupal\services\Controller\ServiceEndpointManageResource.

Namespace

Drupal\services\Controller

Code

public function displayList(ServiceEndpointInterface $service_endpoint = NULL) {
  $build = [];
  foreach ($this
    ->getCategoryDefinitions($service_endpoint) as $category => $definitions) {
    if (!isset($category)) {
      continue;
    }
    $build[$category] = [
      '#type' => 'details',
      '#title' => $this
        ->t('@category', [
        '@category' => $category,
      ]),
      '#tree' => TRUE,
    ];
    $rows = [];
    foreach ($definitions as $plugin_id => $definition) {
      $row = $this
        ->buildRow($service_endpoint, $definition);
      $row['operations']['data'] = [
        '#type' => 'dropbutton',
        '#links' => $this
          ->buildOperationLinks($service_endpoint, $plugin_id),
      ];
      $rows[] = $row;
    }
    $build[$category]['table'] = array(
      '#type' => 'table',
      '#rows' => $rows,
      '#header' => $this
        ->buildHeader(),
      '#empty' => $this
        ->t('No service definitions exist'),
    );
  }
  return $build;
}