public function WebformSubmissionListBuilder::getDefaultOperations in Webform 6.x
Same name and namespace in other branches
- 8.5 src/WebformSubmissionListBuilder.php \Drupal\webform\WebformSubmissionListBuilder::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
- src/
WebformSubmissionListBuilder.php, line 1018
Class
- WebformSubmissionListBuilder
- Provides a list controller for webform submission entity.
Namespace
Drupal\webformCode
public function getDefaultOperations(EntityInterface $entity) {
/** @var \Drupal\webform\WebformInterface $webform */
$webform = $entity
->getWebform();
$operations = [];
if ($this->account) {
if ($entity
->access('update')) {
$operations['edit'] = [
'title' => $this
->t('Edit'),
'weight' => 10,
'url' => $this->requestHandler
->getUrl($entity, $this->sourceEntity, 'webform.user.submission.edit'),
];
}
if ($entity
->access('view')) {
$operations['view'] = [
'title' => $this
->t('View'),
'weight' => 20,
'url' => $this->requestHandler
->getUrl($entity, $this->sourceEntity, 'webform.user.submission'),
];
}
if ($entity
->access('duplicate') && $webform
->getSetting('submission_user_duplicate')) {
$operations['duplicate'] = [
'title' => $this
->t('Duplicate'),
'weight' => 30,
'url' => $this->requestHandler
->getUrl($entity, $this->sourceEntity, 'webform.user.submission.duplicate'),
];
}
if ($entity
->access('delete')) {
$operations['delete'] = [
'title' => $this
->t('Delete'),
'weight' => 100,
'url' => $this->requestHandler
->getUrl($entity, $this->sourceEntity, 'webform.user.submission.delete'),
'attributes' => WebformDialogHelper::getModalDialogAttributes(WebformDialogHelper::DIALOG_NARROW),
];
}
}
else {
if ($entity
->access('update')) {
$operations['edit'] = [
'title' => $this
->t('Edit'),
'weight' => 10,
'url' => $this->requestHandler
->getUrl($entity, $this->sourceEntity, 'webform_submission.edit_form'),
];
}
if ($entity
->access('view')) {
$operations['view'] = [
'title' => $this
->t('View'),
'weight' => 20,
'url' => $this->requestHandler
->getUrl($entity, $this->sourceEntity, 'webform_submission.canonical'),
];
}
if ($entity
->access('notes')) {
$operations['notes'] = [
'title' => $this
->t('Notes'),
'weight' => 30,
'url' => $this->requestHandler
->getUrl($entity, $this->sourceEntity, 'webform_submission.notes_form'),
];
}
if ($entity
->access('resend') && $webform
->hasMessageHandler()) {
$operations['resend'] = [
'title' => $this
->t('Resend'),
'weight' => 40,
'url' => $this->requestHandler
->getUrl($entity, $this->sourceEntity, 'webform_submission.resend_form'),
];
}
if ($entity
->access('duplicate')) {
$operations['duplicate'] = [
'title' => $this
->t('Duplicate'),
'weight' => 50,
'url' => $this->requestHandler
->getUrl($entity, $this->sourceEntity, 'webform_submission.duplicate_form'),
];
}
if ($entity
->access('delete')) {
$operations['delete'] = [
'title' => $this
->t('Delete'),
'weight' => 100,
'url' => $this->requestHandler
->getUrl($entity, $this->sourceEntity, 'webform_submission.delete_form'),
'attributes' => WebformDialogHelper::getModalDialogAttributes(WebformDialogHelper::DIALOG_NARROW),
];
}
if ($entity
->access('view_any') && $this->currentUser
->hasPermission('access webform submission log') && $webform
->hasSubmissionLog() && $this->moduleHandler
->moduleExists('webform_submission_log')) {
$operations['log'] = [
'title' => $this
->t('Log'),
'weight' => 100,
'url' => $this->requestHandler
->getUrl($entity, $this->sourceEntity, 'webform_submission.log'),
];
}
}
// Add destination to all operation links.
foreach ($operations as &$operation) {
$this
->ensureDestination($operation['url']);
}
return $operations;
}