You are here

protected function ScheduledTransitionsListBuilder::getDefaultOperations in Scheduled Transitions 8

Same name and namespace in other branches
  1. 2.x src/ScheduledTransitionsListBuilder.php \Drupal\scheduled_transitions\ScheduledTransitionsListBuilder::getDefaultOperations()

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 EntityListBuilder::getDefaultOperations

File

src/ScheduledTransitionsListBuilder.php, line 106

Class

ScheduledTransitionsListBuilder
Scheduled transition list builder.

Namespace

Drupal\scheduled_transitions

Code

protected function getDefaultOperations(EntityInterface $entity) {
  $operations = parent::getDefaultOperations($entity);
  $rescheduleUrl = $entity
    ->toUrl('reschedule-form');

  // @todo improve access cacheability after
  // https://www.drupal.org/project/drupal/issues/3106517 +
  // https://www.drupal.org/project/drupal/issues/2473873 for now permissions
  // cache context is added manually in buildOperations.
  if ($rescheduleUrl
    ->access()) {
    $operations['reschedule'] = [
      'title' => $this
        ->t('Reschedule'),
      'weight' => 20,
      'url' => $this
        ->ensureDestination($rescheduleUrl),
      'attributes' => [
        'class' => [
          'use-ajax',
        ],
        'data-dialog-type' => 'modal',
        'data-dialog-options' => Json::encode([
          'width' => 500,
        ]),
      ],
    ];
  }
  return $operations;
}