You are here

public function LanguageListBuilder::buildRow in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/language/src/LanguageListBuilder.php \Drupal\language\LanguageListBuilder::buildRow()
  2. 10 core/modules/language/src/LanguageListBuilder.php \Drupal\language\LanguageListBuilder::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 DraggableListBuilder::buildRow

See also

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

File

core/modules/language/src/LanguageListBuilder.php, line 115

Class

LanguageListBuilder
Defines a class to build a listing of language entities.

Namespace

Drupal\language

Code

public function buildRow(EntityInterface $entity) {
  $row['label'] = $entity
    ->label();
  $row['default'] = [
    '#type' => 'radio',
    '#parents' => [
      'site_default_language',
    ],
    '#title' => t('Set @title as default', [
      '@title' => $entity
        ->label(),
    ]),
    '#title_display' => 'invisible',
    '#return_value' => $entity
      ->id(),
    '#id' => 'edit-site-default-language-' . $entity
      ->id(),
  ];

  // Mark the right language as default in the form.
  if ($entity
    ->id() == $this->languageManager
    ->getDefaultLanguage()
    ->getId()) {
    $row['default']['#default_value'] = $entity
      ->id();
  }
  return $row + parent::buildRow($entity);
}