function EntityListBuilder::render

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityListBuilder.php \Drupal\Core\Entity\EntityListBuilder::render()
  2. 10 core/lib/Drupal/Core/Entity/EntityListBuilder.php \Drupal\Core\Entity\EntityListBuilder::render()
  3. 11.x core/lib/Drupal/Core/Entity/EntityListBuilder.php \Drupal\Core\Entity\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

13 calls to EntityListBuilder::render()
ActionListBuilder::render in core/modules/action/src/ActionListBuilder.php
Builds the entity listing as renderable array for table.html.twig.
ConfigTranslationEntityListBuilder::render in core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php
Builds the entity listing as renderable array for table.html.twig.
DraggableListBuilder::render in core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php
Builds the entity listing as renderable array for table.html.twig.
FieldConfigListBuilder::render in core/modules/field_ui/src/FieldConfigListBuilder.php
Builds the entity listing as renderable array for table.html.twig.
ImageStyleListBuilder::render in core/modules/image/src/ImageStyleListBuilder.php
Builds the entity listing as renderable array for table.html.twig.

... See full list

16 methods override EntityListBuilder::render()
ActionListBuilder::render in core/modules/action/src/ActionListBuilder.php
Builds the entity listing as renderable array for table.html.twig.
BlockListBuilder::render in core/modules/block/src/BlockListBuilder.php
ConfigTranslationEntityListBuilder::render in core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php
Builds the entity listing as renderable array for table.html.twig.
DraggableListBuilder::render in core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php
Builds the entity listing as renderable array for table.html.twig.
EntityDisplayModeListBuilder::render in core/modules/field_ui/src/EntityDisplayModeListBuilder.php
Builds the entity listing as renderable array for table.html.twig.

... See full list

File

core/lib/Drupal/Core/Entity/EntityListBuilder.php, line 206

Class

EntityListBuilder
Defines a generic implementation to build a listing of entities.

Namespace

Drupal\Core\Entity

Code

public function render() {
    $build['table'] = [
        '#type' => 'table',
        '#header' => $this->buildHeader(),
        '#title' => $this->getTitle(),
        '#rows' => [],
        '#empty' => $this->t('There are no @label yet.', [
            '@label' => $this->entityType
                ->getPluralLabel(),
        ]),
        '#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'] = [
            '#type' => 'pager',
        ];
    }
    return $build;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.