You are here

public function GridStackListBuilder::getDefaultOperations in GridStack 8

Same name and namespace in other branches
  1. 8.2 modules/gridstack_ui/src/Controller/GridStackListBuilder.php \Drupal\gridstack_ui\Controller\GridStackListBuilder::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/gridstack_ui/src/Controller/GridStackListBuilder.php, line 138

Class

GridStackListBuilder
Provides a listing of GridStack optionsets.

Namespace

Drupal\gridstack_ui\Controller

Code

public function getDefaultOperations(EntityInterface $entity) {
  $operations = parent::getDefaultOperations($entity);
  if (isset($operations['edit'])) {
    $operations['edit']['title'] = $this
      ->t('Configure');
  }
  $operations['duplicate'] = [
    'title' => $this
      ->t('Duplicate'),
    'weight' => 15,
    'url' => $entity
      ->toUrl('duplicate-form'),
  ];
  if ($entity
    ->id() == 'default') {
    unset($operations['delete'], $operations['edit']);
  }
  if ($entity
    ->id() == 'frontend') {
    unset($operations['delete']);
  }
  return $operations;
}