public function VocabularyListController::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 of fields for this entity.

Overrides EntityListController::buildRow

See also

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

1 call to VocabularyListController::buildRow()
VocabularyListController::buildForm in drupal/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php
Form constructor.

File

drupal/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php, line 65
Contains \Drupal\taxonomy\VocabularyListController.

Class

VocabularyListController
Provides a listing of vocabularies.

Namespace

Drupal\taxonomy

Code

public function buildRow(EntityInterface $entity) {
  $row = parent::buildRow($entity);

  // Override default values to markup elements.
  $row['#attributes']['class'][] = 'draggable';
  unset($row['id']);
  $row['label'] = array(
    '#markup' => check_plain($row['label']),
  );
  $row['#weight'] = $entity
    ->get('weight');

  // Add weight column.
  $row['weight'] = array(
    '#type' => 'weight',
    '#title' => t('Weight for @title', array(
      '@title' => $entity
        ->label(),
    )),
    '#title_display' => 'invisible',
    '#default_value' => $entity
      ->get('weight'),
    '#attributes' => array(
      'class' => array(
        'weight',
      ),
    ),
  );
  return $row;
}