You are here

public function WebhookConfigListBuilder::getOperations in Webhooks 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

1 call to WebhookConfigListBuilder::getOperations()
WebhookConfigListBuilder::buildOperations in src/WebhookConfigListBuilder.php
Builds a renderable list of operation links for the entity.

File

src/WebhookConfigListBuilder.php, line 17

Class

WebhookConfigListBuilder
Provides a listing of Webhook entities.

Namespace

Drupal\webhooks

Code

public function getOperations(EntityInterface $entity) {
  $operations = parent::getOperations($entity);
  $operations['toggle_active'] = [
    'title' => $entity
      ->status() ? t('Deactivate') : t('Activate'),
    'weight' => 50,
    'url' => Url::fromRoute('webhooks.webhook_toggle_active', [
      'id' => $entity
        ->id(),
    ]),
  ];
  uasort($operations, '\\Drupal\\Component\\Utility\\SortArray::sortByWeightElement');
  return $operations;
}