You are here

public function AssetInjectorListBuilder::getDefaultOperations in Asset Injector 8.2

Same name and namespace in other branches
  1. 8 src/AssetInjectorListBuilder.php \Drupal\asset_injector\AssetInjectorListBuilder::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/AssetInjectorListBuilder.php, line 62

Class

AssetInjectorListBuilder
Provides a listing of Asset Injector entities.

Namespace

Drupal\asset_injector

Code

public function getDefaultOperations(EntityInterface $entity) {
  $operations = parent::getDefaultOperations($entity);
  if ($entity
    ->hasLinkTemplate('duplicate-form')) {
    $operations['duplicate'] = [
      'title' => $this
        ->t('Duplicate'),
      'weight' => 15,
      'url' => $entity
        ->toUrl('duplicate-form'),
    ];
  }

  // Remove query option to allow the save and continue to correctly function.
  $options = $operations['edit']['url']
    ->getOptions();
  unset($options['query']);
  $operations['edit']['url']
    ->setOptions($options);
  return $operations;
}