You are here

class LanguageArgument in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/argument/LanguageArgument.php \Drupal\views\Plugin\views\argument\LanguageArgument
  2. 9 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

  • class \Drupal\views\Plugin\views\argument\LanguageArgument extends \Drupal\views\Plugin\views\argument\ArgumentPluginBase

Expanded class hierarchy of LanguageArgument

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

}

Members

Namesort descending Modifiers Type Description Overrides
LanguageArgument::language public function Returns the language name for a given langcode.
LanguageArgument::summaryName public function Overrides \Drupal\views\Plugin\views\argument\ArgumentPluginBase::summaryName().
LanguageArgument::title public function Overrides \Drupal\views\Plugin\views\argument\ArgumentPluginBase::title().