function DraggableListBuilderTrait::buildRow

Same name in other branches
  1. 10 core/lib/Drupal/Core/Entity/DraggableListBuilderTrait.php \Drupal\Core\Entity\DraggableListBuilderTrait::buildRow()

Builds a row for an entity in the entity listing.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.

Return value

array A render array structure for an entity row.

See also

\Drupal\Core\Entity\EntityListBuilder::buildRow()

6 calls to DraggableListBuilderTrait::buildRow()
DraggableListBuilderTrait::buildForm in core/lib/Drupal/Core/Entity/DraggableListBuilderTrait.php
Form constructor.
FilterFormatListBuilder::buildRow in core/modules/filter/src/FilterFormatListBuilder.php
LanguageListBuilder::buildRow in core/modules/language/src/LanguageListBuilder.php
RoleListBuilder::buildRow in core/modules/user/src/RoleListBuilder.php
SearchPageListBuilder::buildRow in core/modules/search/src/SearchPageListBuilder.php

... See full list

5 methods override DraggableListBuilderTrait::buildRow()
FilterFormatListBuilder::buildRow in core/modules/filter/src/FilterFormatListBuilder.php
LanguageListBuilder::buildRow in core/modules/language/src/LanguageListBuilder.php
RoleListBuilder::buildRow in core/modules/user/src/RoleListBuilder.php
SearchPageListBuilder::buildRow in core/modules/search/src/SearchPageListBuilder.php
VocabularyListBuilder::buildRow in core/modules/taxonomy/src/VocabularyListBuilder.php

File

core/lib/Drupal/Core/Entity/DraggableListBuilderTrait.php, line 93

Class

DraggableListBuilderTrait
Provides a trait for draggable listings of entities.

Namespace

Drupal\Core\Entity

Code

public function buildRow(EntityInterface $entity) {
    $row = [];
    if (!empty($this->weightKey)) {
        // Override default values to markup elements.
        $row['#attributes']['class'][] = 'draggable';
        $row['#weight'] = $this->getWeight($entity);
        // Add weight column.
        $row['weight'] = [
            '#type' => 'weight',
            '#title' => t('Weight for @title', [
                '@title' => $entity->label(),
            ]),
            '#title_display' => 'invisible',
            '#default_value' => $this->getWeight($entity),
            '#attributes' => [
                'class' => [
                    'weight',
                ],
            ],
        ];
    }
    return $row + parent::buildRow($entity);
}

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