function EntityListBuilder::render

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityListBuilder.php \Drupal\Core\Entity\EntityListBuilder::render()
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityListBuilder.php \Drupal\Core\Entity\EntityListBuilder::render()
  3. 10 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.
FieldConfigListBuilder::render in core/modules/field_ui/src/FieldConfigListBuilder.php
Builds the entity listing as renderable array for table.html.twig.
FieldStorageConfigListBuilder::render in core/modules/field_ui/src/FieldStorageConfigListBuilder.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

17 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.
EntityDisplayModeListBuilder::render in core/modules/field_ui/src/EntityDisplayModeListBuilder.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.

... See full list

File

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

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.