class LanguageArgument

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/argument/LanguageArgument.php \Drupal\views\Plugin\views\argument\LanguageArgument
  2. 10 core/modules/views/src/Plugin/views/argument/LanguageArgument.php \Drupal\views\Plugin\views\argument\LanguageArgument
  3. 8.9.x core/modules/views/src/Plugin/views/argument/LanguageArgument.php \Drupal\views\Plugin\views\argument\LanguageArgument

Defines an argument handler to accept a language.

Plugin annotation

@ViewsArgument("language");

Hierarchy

Expanded class hierarchy of LanguageArgument

Related topics

File

core/modules/views/src/Plugin/views/argument/LanguageArgument.php, line 12

Namespace

Drupal\views\Plugin\views\argument
View source
class LanguageArgument extends ArgumentPluginBase {
  
  /**
   * Overrides \Drupal\views\Plugin\views\argument\ArgumentPluginBase::summaryName().
   *
   * Gets the user-friendly version of the language name.
   */
  public function summaryName($data) {
    return $this->language($data->{$this->name_alias});
  }
  
  /**
   * Overrides \Drupal\views\Plugin\views\argument\ArgumentPluginBase::title().
   *
   * Gets the user friendly version of the language name for display as a
   * title placeholder.
   */
  public function title() {
    return $this->language($this->argument);
  }
  
  /**
   * Returns the language name for a given langcode.
   *
   * @param string $langcode
   *   The language code.
   *
   * @return string
   *   The translated name for the language, or "Unknown language" if the
   *   language was not found.
   */
  public function language($langcode) {
    $languages = $this->listLanguages();
    return $languages[$langcode] ?? $this->t('Unknown language');
  }

}

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