You are here

public function ConsumerListBuilder::getOperations in Consumers 8

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/ConsumerListBuilder.php, line 58

Class

ConsumerListBuilder
Defines a class to build a listing of Access Token entities.

Namespace

Drupal\consumers

Code

public function getOperations(EntityInterface $entity) {
  $operations = parent::getOperations($entity);
  if ($entity
    ->access('update') && $entity
    ->hasLinkTemplate('make-default-form') && !$entity
    ->get('is_default')->value) {
    $operations['make-default'] = [
      'title' => $this
        ->t('Make Default'),
      'weight' => 10,
      'url' => $this
        ->ensureDestination($entity
        ->toUrl('make-default-form')),
    ];
  }
  return $operations;
}