public EntityDisplayModeListBuilder::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/field_ui/src/EntityDisplayModeListBuilder.php, line 84
Class
- EntityDisplayModeListBuilder
- Defines a class to build a listing of view mode entities.
Namespace
Drupal\field_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 | public function render() { $build = array (); foreach ( $this ->load() as $entity_type => $entities ) { if (!isset( $this ->entityTypes[ $entity_type ])) { continue ; } // Filter entities. if (! $this ->isValidEntity( $entity_type )) { continue ; } $table = array ( '#prefix' => '<h2>' . $this ->entityTypes[ $entity_type ]->getLabel() . '</h2>' , '#type' => 'table' , '#header' => $this ->buildHeader(), '#rows' => array (), ); foreach ( $entities as $entity ) { if ( $row = $this ->buildRow( $entity )) { $table [ '#rows' ][ $entity ->id()] = $row ; } } // Move content at the top. if ( $entity_type == 'node' ) { $table [ '#weight' ] = -10; } $short_type = str_replace ( array ( 'entity_' , '_mode' ), '' , $this ->entityTypeId); $table [ '#rows' ][ '_add_new' ][] = array ( 'data' => array ( '#type' => 'link' , '#url' => Url::fromRoute( $short_type == 'view' ? 'entity.entity_view_mode.add_form' : 'entity.entity_form_mode.add_form' , [ 'entity_type_id' => $entity_type ]), '#title' => $this ->t( 'Add new %label @entity-type' , array ( '%label' => $this ->entityTypes[ $entity_type ]->getLabel(), '@entity-type' => $this ->entityType->getLowercaseLabel())), ), 'colspan' => count ( $table [ '#header' ]), ); $build [ $entity_type ] = $table ; } return $build ; } |
Please login to continue.