You are here

protected function PaymentListBuilder::getDefaultOperations in Payment 8.2

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/Entity/Payment/PaymentListBuilder.php, line 180

Class

PaymentListBuilder
Lists payment entities.

Namespace

Drupal\payment\Entity\Payment

Code

protected function getDefaultOperations(EntityInterface $entity) {
  $destination = $this->redirectDestination
    ->get();
  $operations = parent::getDefaultOperations($entity);
  foreach ($operations as &$operation) {
    $operation['query']['destination'] = $destination;
  }
  if ($entity
    ->access('view')) {
    $operations['view'] = array(
      'title' => $this
        ->t('View'),
      'weight' => -10,
      'url' => $entity
        ->toUrl(),
    );
  }
  if ($entity
    ->access('update_status')) {
    $operations['update_status'] = array(
      'title' => $this
        ->t('Update status'),
      'attributes' => array(
        'data-accepts' => 'application/vnd.drupal-modal',
      ),
      'query' => array(
        'destination' => $destination,
      ),
      'url' => $entity
        ->toUrl('update-status-form'),
    );
  }
  if ($entity
    ->access('capture')) {
    $operations['capture'] = array(
      'title' => $this
        ->t('Capture'),
      'attributes' => array(
        'data-accepts' => 'application/vnd.drupal-modal',
      ),
      'query' => array(
        'destination' => $destination,
      ),
      'url' => $entity
        ->toUrl('capture-form'),
    );
  }
  if ($entity
    ->access('refund')) {
    $operations['refund'] = array(
      'title' => $this
        ->t('Refund'),
      'attributes' => array(
        'data-accepts' => 'application/vnd.drupal-modal',
      ),
      'query' => array(
        'destination' => $destination,
      ),
      'url' => $entity
        ->toUrl('refund-form'),
    );
  }
  if ($entity
    ->access('complete')) {
    $operations['complete'] = array(
      'title' => $this
        ->t('Complete'),
      'url' => $entity
        ->toUrl('complete'),
    );
  }
  return $operations;
}