You are here

public function ScheduleListBuilder::render in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/ScheduleListBuilder.php \Drupal\business_rules\ScheduleListBuilder::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/ScheduleListBuilder.php, line 97

Class

ScheduleListBuilder
Defines a class to build a listing of Schedule entities.

Namespace

Drupal\business_rules

Code

public function render() {
  $output['#attached']['library'][] = 'system/drupal.system.modules';
  $output['filters'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'table-filter',
        'js-show',
      ],
    ],
  ];
  $output['filters']['text'] = [
    '#type' => 'search',
    '#title' => $this
      ->t('Search'),
    '#size' => 30,
    '#placeholder' => $this
      ->t('Search for a item'),
    '#attributes' => [
      'class' => [
        'table-filter-text',
      ],
      'data-table' => '.searchable-list',
      'autocomplete' => 'off',
      'title' => $this
        ->t('Enter a part of the item to filter by.'),
    ],
  ];
  $output += parent::render();
  if (!isset($output['table']['#attributes']['class'])) {
    $output['table']['#attributes']['class'] = [
      'searchable-list',
    ];
  }
  else {
    $output['table']['#attributes']['class'][] = [
      'searchable-list',
    ];
  }
  return $output;
}