public EntityListBuilder::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 EntityListBuilderInterface::render
File
- core/lib/Drupal/Core/Entity/EntityListBuilder.php, line 216
Class
- EntityListBuilder
- Defines a generic implementation to build a listing of entities.
Namespace
Drupal\Core\Entity
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 | public function render() { $build [ 'table' ] = array ( '#type' => 'table' , '#header' => $this ->buildHeader(), '#title' => $this ->getTitle(), '#rows' => array (), '#empty' => $this ->t( 'There is no @label yet.' , array ( '@label' => $this ->entityType->getLabel())), '#cache' => [ 'contexts' => $this ->entityType->getListCacheContexts(), 'tags' => $this ->entityType->getListCacheTags(), ], ); foreach ( $this ->load() as $entity ) { if ( $row = $this ->buildRow( $entity )) { $build [ 'table' ][ '#rows' ][ $entity ->id()] = $row ; } } // Only add the pager if a limit is specified. if ( $this ->limit) { $build [ 'pager' ] = array ( '#type' => 'pager' , ); } return $build ; } |
Please login to continue.