You are here

public function ConfigTranslationEntityListBuilder::render in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php \Drupal\config_translation\Controller\ConfigTranslationEntityListBuilder::render()
  2. 10 core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php \Drupal\config_translation\Controller\ConfigTranslationEntityListBuilder::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

core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php, line 28

Class

ConfigTranslationEntityListBuilder
Defines the configuration translation list builder for entities.

Namespace

Drupal\config_translation\Controller

Code

public function render() {
  $build = parent::render();
  $filter = $this
    ->getFilterLabels();
  usort($build['table']['#rows'], [
    $this,
    'sortRows',
  ]);
  $build['filters'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'table-filter',
        'js-show',
      ],
    ],
    '#weight' => -10,
  ];
  $build['filters']['text'] = [
    '#type' => 'search',
    '#title' => $this
      ->t('Search'),
    '#size' => 30,
    '#placeholder' => $filter['placeholder'],
    '#attributes' => [
      'class' => [
        'table-filter-text',
      ],
      'data-table' => '.config-translation-entity-list',
      'autocomplete' => 'off',
      'title' => $filter['description'],
    ],
  ];
  $build['table']['#attributes']['class'][] = 'config-translation-entity-list';
  $build['table']['#weight'] = 0;
  $build['#attached']['library'][] = 'system/drupal.system.modules';
  return $build;
}