You are here

protected function ServiceEndpointResources::buildOperationLinks in Services 8.4

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

Build service resource operations links.

Parameters

\Drupal\services\ServiceEndpointInterface $service_endpoint: An service endpoint object.

string $plugin_id: An service plugin identifier.

Return value

array An array of operations links.

1 call to ServiceEndpointResources::buildOperationLinks()
ServiceEndpointResources::displayList in src/Controller/ServiceEndpointResources.php
List service resources.

File

src/Controller/ServiceEndpointResources.php, line 130

Class

ServiceEndpointResources
Class \Drupal\services\Controller\ServiceEndpointManageResource.

Namespace

Drupal\services\Controller

Code

protected function buildOperationLinks(ServiceEndpointInterface $service_endpoint, $plugin_id) {
  $links = [];
  $links['configure'] = [
    'title' => $this
      ->t('Enable'),
    'url' => Url::fromRoute('entity.service_endpoint_resource.config_form', [
      'plugin_id' => $plugin_id,
      'service_endpoint' => $service_endpoint
        ->id(),
    ]),
    'attributes' => $this
      ->getModalAttributes(),
  ];
  if ($service_resource = $service_endpoint
    ->loadResourceProvider($plugin_id)) {
    if ($service_resource
      ->hasLinkTemplate('delete-form')) {
      $links['disable'] = [
        'title' => $this
          ->t('Disable'),
        'url' => $service_resource
          ->toUrl('delete-form'),
        'attributes' => $this
          ->getModalAttributes(),
      ];
    }
    $links['configure']['title'] = $this
      ->t('Configure');
  }
  return $links;
}