You are here

public function YamlFormEntityListBuilder::getDefaultOperations in YAML Form 8

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

1 call to YamlFormEntityListBuilder::getDefaultOperations()
YamlFormEntityListBuilder::buildRow in src/YamlFormEntityListBuilder.php
Builds a row for an entity in the entity listing.

File

src/YamlFormEntityListBuilder.php, line 187

Class

YamlFormEntityListBuilder
Defines a class to build a listing of form entities.

Namespace

Drupal\yamlform

Code

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

  /* @var $entity \Drupal\yamlform\YamlFormInterface */
  $route_parameters = [
    'yamlform' => $entity
      ->id(),
  ];
  if ($type == 'results') {
    $operations = [];
    if ($entity
      ->access('submission_view_any')) {
      $operations['submissions'] = [
        'title' => $this
          ->t('Submissions'),
        'url' => Url::fromRoute('entity.yamlform.results_submissions', $route_parameters),
      ];
      $operations['table'] = [
        'title' => $this
          ->t('Table'),
        'url' => Url::fromRoute('entity.yamlform.results_table', $route_parameters),
      ];
      $operations['export'] = [
        'title' => $this
          ->t('Download'),
        'url' => Url::fromRoute('entity.yamlform.results_export', $route_parameters),
      ];
    }
    if ($entity
      ->access('submission_delete_any')) {
      $operations['clear'] = [
        'title' => $this
          ->t('Clear'),
        'url' => Url::fromRoute('entity.yamlform.results_clear', $route_parameters),
      ];
    }
  }
  else {
    $operations = parent::getDefaultOperations($entity);
    if ($entity
      ->access('view')) {
      $operations['view'] = [
        'title' => $this
          ->t('View'),
        'weight' => 20,
        'url' => Url::fromRoute('entity.yamlform.canonical', $route_parameters),
      ];
    }
    if ($entity
      ->access('submission_update_any')) {
      $operations['test'] = [
        'title' => $this
          ->t('Test'),
        'weight' => 21,
        'url' => Url::fromRoute('entity.yamlform.test', $route_parameters),
      ];
    }
    if ($entity
      ->access('duplicate')) {
      $operations['duplicate'] = [
        'title' => $this
          ->t('Duplicate'),
        'weight' => 23,
        'url' => Url::fromRoute('entity.yamlform.duplicate_form', $route_parameters),
        'attributes' => YamlFormDialogHelper::getModalDialogAttributes(640),
      ];
    }
  }
  return $operations;
}