You are here

public function Language::getLinks in Config Pages 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/ConfigPagesContext/Language.php \Drupal\config_pages\Plugin\ConfigPagesContext\Language::getLinks()

Get array of available links to switch on given context.

Return value

array Return array of available links to switch on given context.

Overrides ConfigPagesContextBase::getLinks

File

src/Plugin/ConfigPagesContext/Language.php, line 75

Class

Language
Provides a language config pages context.

Namespace

Drupal\config_pages\Plugin\ConfigPagesContext

Code

public function getLinks() {
  $links = [];
  $value = $this
    ->getValue();
  $languages = $this->languageManager
    ->getLanguages();
  foreach ($languages as $lang) {
    $links[] = [
      'title' => $lang
        ->getName(),
      'href' => Url::fromRoute('<current>', [], [
        'language' => $lang,
      ]),
      'selected' => $value == $lang
        ->getId() ? TRUE : FALSE,
      'value' => $lang
        ->getId(),
    ];
  }
  return $links;
}