function ViewListBuilder::render
Same name in other branches
- 8.9.x core/modules/views_ui/src/ViewListBuilder.php \Drupal\views_ui\ViewListBuilder::render()
- 10 core/modules/views_ui/src/ViewListBuilder.php \Drupal\views_ui\ViewListBuilder::render()
- 11.x core/modules/views_ui/src/ViewListBuilder.php \Drupal\views_ui\ViewListBuilder::render()
Overrides EntityListBuilder::render
File
-
core/
modules/ views_ui/ src/ ViewListBuilder.php, line 193
Class
- ViewListBuilder
- Defines a class to build a listing of view entities.
Namespace
Drupal\views_uiCode
public function render() {
$entities = $this->load();
$list['#type'] = 'container';
$list['#attributes']['id'] = 'views-entity-list';
$list['#attached']['library'][] = 'core/drupal.ajax';
$list['#attached']['library'][] = 'views_ui/views_ui.listing';
$list['filters'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'table-filter',
'js-show',
],
],
];
$list['filters']['text'] = [
'#type' => 'search',
'#title' => $this->t('Filter'),
'#title_display' => 'invisible',
'#size' => 60,
'#placeholder' => $this->t('Filter by view name, machine name, description, or display path'),
'#attributes' => [
'class' => [
'views-filter-text',
],
'data-table' => '.views-listing-table',
'autocomplete' => 'off',
'title' => $this->t('Enter a part of the view name, machine name, description, or display path to filter by.'),
],
];
$list['enabled']['heading']['#markup'] = '<h2>' . $this->t('Enabled', [], [
'context' => 'Plural',
]) . '</h2>';
$list['disabled']['heading']['#markup'] = '<h2>' . $this->t('Disabled', [], [
'context' => 'Plural',
]) . '</h2>';
foreach ([
'enabled',
'disabled',
] as $status) {
$list[$status]['#type'] = 'container';
$list[$status]['#attributes'] = [
'class' => [
'views-list-section',
$status,
],
];
$list[$status]['table'] = [
'#theme' => 'views_ui_views_listing_table',
'#headers' => $this->buildHeader(),
'#attributes' => [
'class' => [
'views-listing-table',
$status,
],
],
];
foreach ($entities[$status] as $entity) {
$list[$status]['table']['#rows'][$entity->id()] = $this->buildRow($entity);
}
}
$list['enabled']['table']['#empty'] = $this->t('There are no enabled views.');
$list['disabled']['table']['#empty'] = $this->t('There are no disabled views.');
return $list;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.