public function RoleListController::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 RoleListController::buildRow()
RoleListController::buildForm in drupal/core/modules/user/lib/Drupal/user/RoleListController.php
Form constructor.

File

drupal/core/modules/user/lib/Drupal/user/RoleListController.php, line 58
Contains \Drupal\user\RoleListController.

Class

RoleListController
Provides a listing of user roles.

Namespace

Drupal\user

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;
}