You are here

public function WebformSubmissionListBuilder::render in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformSubmissionListBuilder.php \Drupal\webform\WebformSubmissionListBuilder::render()

Builds the entity listing as renderable array for table.html.twig.

@todo Add a link to add a new item to the #empty text.

Overrides EntityListBuilder::render

File

src/WebformSubmissionListBuilder.php, line 426

Class

WebformSubmissionListBuilder
Provides a list controller for webform submission entity.

Namespace

Drupal\webform

Code

public function render() {
  $build = [];

  // Set user specific page title.
  if ($this->webform && $this->account) {
    $t_args = [
      '%webform' => $this->webform
        ->label(),
      '%user' => $this->account
        ->getDisplayName(),
    ];
    if ($this->draft) {
      $build['#title'] = $this
        ->t('Drafts for %webform for %user', $t_args);
    }
    else {
      $build['#title'] = $this
        ->t('Submissions to %webform for %user', $t_args);
    }
  }
  elseif ($this->account) {
    $build['#title'] = $this->account
      ->getDisplayName();
  }

  // Display warning when the webform has a submission but saving of results.
  // are disabled.
  if ($this->webform && $this->webform
    ->getSetting('results_disabled')) {
    $this->messageManager
      ->display(WebformMessageManagerInterface::FORM_SAVE_EXCEPTION, 'warning');
  }
  $build += $this
    ->buildSubmissionViewsMenu();
  if ($this->submissionView) {
    $build += $this
      ->buildSubmissionViews();
  }
  else {
    $build += $this
      ->buildEntityList();
  }
  $build['#attached']['library'][] = 'webform/webform.admin';
  return $build;
}