You are here

public function KeyListBuilder::getOperations in Key 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/Controller/KeyListBuilder.php, line 97

Class

KeyListBuilder
Provides a listing of keys.

Namespace

Drupal\key\Controller

Code

public function getOperations(EntityInterface $entity) {

  /* @var $key \Drupal\key\Entity\Key */
  $key = $entity;
  $operations = parent::getOperations($key);
  $key_collection = Url::fromRoute('entity.key.collection')
    ->toString();
  $operations['add_override'] = [
    'title' => $this
      ->t('Add Config Override'),
    'weight' => 50,
    'url' => Url::fromRoute('entity.key_config_override.add_form', [], [
      'query' => [
        'destination' => $key_collection,
        'key' => $key
          ->id(),
      ],
    ]),
  ];
  uasort($operations, '\\Drupal\\Component\\Utility\\SortArray::sortByWeightElement');
  return $operations;
}