You are here

public function EntityQueueListBuilder::getDefaultOperations in Entityqueue 8

Gets this list's default operations.

Parameters

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

Return value

array The array structure is identical to the return value of self::getOperations().

Overrides ConfigEntityListBuilder::getDefaultOperations

File

src/EntityQueueListBuilder.php, line 155

Class

EntityQueueListBuilder
Defines a class that builds a listing of entity queues.

Namespace

Drupal\entityqueue

Code

public function getDefaultOperations(EntityInterface $entity) {
  assert($entity instanceof EntityQueueInterface);
  $operations = parent::getDefaultOperations($entity);
  if (isset($operations['edit'])) {
    $operations['edit']['title'] = $this
      ->t('Configure');
  }

  // Add AJAX functionality to enable/disable operations.
  foreach ([
    'enable',
    'disable',
  ] as $op) {
    if (isset($operations[$op])) {
      $operations[$op]['url'] = $entity
        ->toUrl($op);

      // Enable and disable operations should use AJAX.
      $operations[$op]['attributes']['class'][] = 'use-ajax';
    }
  }

  // Allow queue handlers to add their own operations.
  $operations += $entity
    ->getHandlerPlugin()
    ->getQueueListBuilderOperations();
  return $operations;
}