public function ViewListBuilder::render in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views_ui/src/ViewListBuilder.php \Drupal\views_ui\ViewListBuilder::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/ views_ui/ src/ ViewListBuilder.php, line 180 - Contains \Drupal\views_ui\ViewListBuilder.
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';
$form['filters'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'table-filter',
'js-show',
),
),
);
$list['filters']['text'] = array(
'#type' => 'search',
'#title' => $this
->t('Filter'),
'#title_display' => 'invisible',
'#size' => 40,
'#placeholder' => $this
->t('Filter by view name or description'),
'#attributes' => array(
'class' => array(
'views-filter-text',
),
'data-table' => '.views-listing-table',
'autocomplete' => 'off',
'title' => $this
->t('Enter a part of the view name or description to filter by.'),
),
);
$list['enabled']['heading']['#markup'] = '<h2>' . $this
->t('Enabled', array(), array(
'context' => 'Plural',
)) . '</h2>';
$list['disabled']['heading']['#markup'] = '<h2>' . $this
->t('Disabled', array(), array(
'context' => 'Plural',
)) . '</h2>';
foreach (array(
'enabled',
'disabled',
) as $status) {
$list[$status]['#type'] = 'container';
$list[$status]['#attributes'] = array(
'class' => array(
'views-list-section',
$status,
),
);
$list[$status]['table'] = array(
'#type' => 'table',
'#attributes' => array(
'class' => array(
'views-listing-table',
),
),
'#header' => $this
->buildHeader(),
'#rows' => array(),
);
foreach ($entities[$status] as $entity) {
$list[$status]['table']['#rows'][$entity
->id()] = $this
->buildRow($entity);
}
}
// @todo Use a placeholder for the entity label if this is abstracted to
// other entity types.
$list['enabled']['table']['#empty'] = $this
->t('There are no enabled views.');
$list['disabled']['table']['#empty'] = $this
->t('There are no disabled views.');
return $list;
}