public function ViewListController::render

Overrides Drupal\Core\Entity\EntityListController::render();

Overrides EntityListController::render

File

drupal/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php, line 131
Definition of Drupal\views_ui\ViewListController.

Class

ViewListController
Provides a listing of Views.

Namespace

Drupal\views_ui

Code

public function render() {
  $entities = $this
    ->load();
  $list['#type'] = 'container';
  $list['#attached']['css'] = ViewFormControllerBase::getAdminCSS();
  $list['#attached']['library'][] = array(
    'system',
    'drupal.ajax',
  );
  $list['#attributes']['id'] = 'views-entity-list';
  $list['enabled']['heading']['#markup'] = '<h2>' . t('Enabled') . '</h2>';
  $list['disabled']['heading']['#markup'] = '<h2>' . t('Disabled') . '</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(
      '#theme' => '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'] = t('There are no enabled views.');
  $list['disabled']['table']['#empty'] = t('There are no disabled views.');
  return $list;
}