W3cubDocs

/Drupal 8

public function DraggableListBuilder::buildRow

public DraggableListBuilder::buildRow(EntityInterface $entity)

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 of fields for this entity.

Overrides EntityListBuilder::buildRow

See also

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

File

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

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 = array();
  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'] = array(
      '#type' => 'weight',
      '#title' => t('Weight for @title', array('@title' => $entity->label())),
      '#title_display' => 'invisible',
      '#default_value' => $entity->get($this->weightKey),
      '#attributes' => array('class' => array('weight')),
    );
  }
  return $row + parent::buildRow($entity);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!Entity!DraggableListBuilder.php/function/DraggableListBuilder::buildRow/8.1.x