function LanguageListBuilder::buildRow

Same name in other branches
  1. 9 core/modules/language/src/LanguageListBuilder.php \Drupal\language\LanguageListBuilder::buildRow()
  2. 8.9.x core/modules/language/src/LanguageListBuilder.php \Drupal\language\LanguageListBuilder::buildRow()
  3. 10 core/modules/language/src/LanguageListBuilder.php \Drupal\language\LanguageListBuilder::buildRow()

Overrides DraggableListBuilderTrait::buildRow

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' => $this->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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.