You are here

public function WebformNodeReferencesListController::getDefaultOperations in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_node/src/Controller/WebformNodeReferencesListController.php \Drupal\webform_node\Controller\WebformNodeReferencesListController::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 EntityListBuilder::getDefaultOperations

File

modules/webform_node/src/Controller/WebformNodeReferencesListController.php, line 341

Class

WebformNodeReferencesListController
Defines a controller for webform node references.

Namespace

Drupal\webform_node\Controller

Code

public function getDefaultOperations(EntityInterface $entity) {
  $route_parameters = [
    'node' => $entity
      ->id(),
  ];
  $operations = [];
  if ($entity
    ->access('update')) {
    $operations['edit'] = [
      'title' => $this
        ->t('Edit'),
      'url' => $this
        ->ensureDestination($entity
        ->toUrl('edit-form')),
    ];
  }
  if ($entity
    ->access('view')) {
    $operations['view'] = [
      'title' => $this
        ->t('View'),
      'url' => $this
        ->ensureDestination($entity
        ->toUrl('canonical')),
    ];
  }
  if ($entity
    ->access('submission_view_any') && !$this->webform
    ->isResultsDisabled()) {
    $operations['results'] = [
      'title' => $this
        ->t('Results'),
      'url' => Url::fromRoute('entity.node.webform.results_submissions', $route_parameters),
    ];
  }
  if ($entity
    ->access('update') && $this->webform
    ->getSetting('share_node', TRUE) && $this
    ->moduleHandler()
    ->moduleExists('webform_share')) {
    $operations['share'] = [
      'title' => $this
        ->t('Share'),
      'url' => Url::fromRoute('entity.node.webform.share_embed', $route_parameters),
    ];
  }
  if ($entity
    ->access('delete')) {
    $operations['delete'] = [
      'title' => $this
        ->t('Delete'),
      'url' => $this
        ->ensureDestination($entity
        ->toUrl('delete-form')),
    ];
  }
  return $operations;
}