function DraggableListBuilder::buildRow

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php \Drupal\Core\Config\Entity\DraggableListBuilder::buildRow()
1 method overrides DraggableListBuilder::buildRow()
LanguageListBuilder::buildRow in core/modules/language/src/LanguageListBuilder.php
Builds a row for an entity in the entity listing.

File

core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php, line 71

Class

DraggableListBuilder
Defines a class to build a draggable listing of configuration entities.

Namespace

Drupal\Core\Config\Entity

Code

public function buildRow(EntityInterface $entity) {
  $row = [];
  if (!empty($this->weightKey)) {
    // Override default values to markup elements.
    $row['#attributes']['class'][] = 'draggable';
    $row['#weight'] = $entity->get($this->weightKey);
    // Add weight column.
    $row['weight'] = [
      '#type' => 'weight',
      '#title' => t('Weight for @title', [
        '@title' => $entity->label(),
      ]),
      '#title_display' => 'invisible',
      '#default_value' => $entity->get($this->weightKey),
      '#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.