You are here

public function WebformEntityListBuilder::render in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformEntityListBuilder.php \Drupal\webform\WebformEntityListBuilder::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/WebformEntityListBuilder.php, line 141

Class

WebformEntityListBuilder
Defines a class to build a listing of webform entities.

Namespace

Drupal\webform

Code

public function render() {

  // Handler autocomplete redirect.
  if ($this->keys && preg_match('#\\(([^)]+)\\)$#', $this->keys, $match)) {
    if ($webform = $this
      ->getStorage()
      ->load($match[1])) {
      return new RedirectResponse($webform
        ->toUrl()
        ->setAbsolute(TRUE)
        ->toString());
    }
  }
  $build = [];

  // Filter form.
  $build['filter_form'] = $this
    ->buildFilterForm();

  // Display info.
  $build['info'] = $this
    ->buildInfo();

  // Table.
  $build += parent::render();
  $build['table']['#sticky'] = TRUE;
  $build['table']['#attributes']['class'][] = 'webform-forms';

  // Bulk operations.
  if ($this->bulkOperations && $this->currentUser
    ->hasPermission('administer webform')) {
    $build['table'] = \Drupal::formBuilder()
      ->getForm('\\Drupal\\webform\\Form\\WebformEntityBulkForm', $build['table']);
  }

  // Attachments.
  // Must preload libraries required by (modal) dialogs.
  WebformDialogHelper::attachLibraries($build);
  $build['#attached']['library'][] = 'webform/webform.admin';
  return $build;
}