You are here

public function ServiceEndpointListBuilder::getOperations in Services 9.0.x

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

Provides an array of information to build a list of operation links.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.

Return value

array An associative array of operation link data for this list, keyed by operation name, containing the following key-value pairs:

  • title: The localized title of the operation.
  • url: An instance of \Drupal\Core\Url for the operation URL.
  • weight: The weight of this operation.

Overrides EntityListBuilder::getOperations

File

src/Controller/ServiceEndpointListBuilder.php, line 36

Class

ServiceEndpointListBuilder
Provides a listing of service endpoint entities.

Namespace

Drupal\services\Controller

Code

public function getOperations(EntityInterface $entity) {
  $operations = parent::getOperations($entity);
  if ($entity
    ->hasLinkTemplate('resources')) {
    $operations['resource'] = [
      'title' => $this
        ->t('Resources'),
      'url' => $entity
        ->toUrl('resources'),
      'weight' => 10,
    ];
  }
  return $operations;
}