You are here

public function WebformAccessGroupListBuilder::getDefaultOperations in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_access/src/WebformAccessGroupListBuilder.php \Drupal\webform_access\WebformAccessGroupListBuilder::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 ConfigEntityListBuilder::getDefaultOperations

File

modules/webform_access/src/WebformAccessGroupListBuilder.php, line 197

Class

WebformAccessGroupListBuilder
Defines a class to build a listing of webform access group entities.

Namespace

Drupal\webform_access

Code

public function getDefaultOperations(EntityInterface $entity, $type = 'edit') {
  $operations = parent::getDefaultOperations($entity);
  if ($entity
    ->access('duplicate')) {
    $operations['duplicate'] = [
      'title' => $this
        ->t('Duplicate'),
      'weight' => 20,
      'url' => Url::fromRoute('entity.webform_access_group.duplicate_form', [
        'webform_access_group' => $entity
          ->id(),
      ]),
    ];
  }
  if (isset($operations['delete'])) {
    $operations['delete']['attributes'] = WebformDialogHelper::getModalDialogAttributes(WebformDialogHelper::DIALOG_NARROW);
  }

  // Changed 'Edit' button label to 'Manage' which better reflects the
  // operation.
  if (!$this->currentUser
    ->hasPermission('administer webform')) {
    $operations['edit']['title'] = $this
      ->t('Manage');
  }
  return $operations;
}