You are here

public function WebformEntityListBuilder::getDefaultOperations in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformEntityListBuilder.php \Drupal\webform\WebformEntityListBuilder::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

src/WebformEntityListBuilder.php, line 391

Class

WebformEntityListBuilder
Defines a class to build a listing of webform entities.

Namespace

Drupal\webform

Code

public function getDefaultOperations(EntityInterface $entity, $type = 'edit') {

  /* @var $entity \Drupal\webform\WebformInterface */
  $operations = [];
  if ($entity
    ->access('update')) {
    $operations['edit'] = [
      'title' => $this
        ->t('Build'),
      'url' => $this
        ->ensureDestination($entity
        ->toUrl('edit-form')),
      'weight' => 0,
    ];
  }
  if ($entity
    ->access('submission_page')) {
    $operations['view'] = [
      'title' => $this
        ->t('View'),
      'url' => $entity
        ->toUrl('canonical'),
      'weight' => 10,
    ];
  }
  if ($entity
    ->access('test')) {
    $operations['test'] = [
      'title' => $this
        ->t('Test'),
      'url' => $entity
        ->toUrl('canonical'),
      'weight' => 20,
    ];
  }
  if ($entity
    ->access('submission_view_any') && !$entity
    ->isResultsDisabled()) {
    $operations['results'] = [
      'title' => $this
        ->t('Results'),
      'url' => $entity
        ->toUrl('results-submissions'),
      'weight' => 30,
    ];
  }
  if ($entity
    ->access('update')) {
    $operations['settings'] = [
      'title' => $this
        ->t('Settings'),
      'url' => $entity
        ->toUrl('settings'),
      'weight' => 40,
    ];
  }
  if ($entity
    ->access('duplicate')) {
    $operations['duplicate'] = [
      'title' => $this
        ->t('Duplicate'),
      'url' => $entity
        ->toUrl('duplicate-form'),
      'attributes' => WebformDialogHelper::getModalDialogAttributes(WebformDialogHelper::DIALOG_NARROW),
      'weight' => 90,
    ];
  }
  if ($entity
    ->access('delete') && $entity
    ->hasLinkTemplate('delete-form')) {
    $operations['delete'] = [
      'title' => $this
        ->t('Delete'),
      'url' => $this
        ->ensureDestination($entity
        ->toUrl('delete-form')),
      'attributes' => WebformDialogHelper::getModalDialogAttributes(WebformDialogHelper::DIALOG_NARROW),
      'weight' => 100,
    ];
  }
  return $operations;
}