public 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
Class
- ViewListBuilder
- Defines a class to build a listing of view entities.
Namespace
Drupal\views_ui
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 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 ; } |
Please login to continue.