You are here

public function WebformOptionsCustomListBuilder::getDefaultOperations in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_options_custom/src/WebformOptionsCustomListBuilder.php \Drupal\webform_options_custom\WebformOptionsCustomListBuilder::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_options_custom/src/WebformOptionsCustomListBuilder.php, line 172

Class

WebformOptionsCustomListBuilder
Defines a class to build a listing of webform options custom entities.

Namespace

Drupal\webform_options_custom

Code

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