Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

LanguageArgument.php

Namespace

Drupal\views\Plugin\views\argument

File

core/modules/views/src/Plugin/views/argument/LanguageArgument.php

View source
<?php

namespace Drupal\views\Plugin\views\argument;

use Drupal\views\Attribute\ViewsArgument;

/**
 * Defines an argument handler to accept a language.
 *
 * @ingroup views_argument_handlers
 */
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');
    }

}

Classes

Title Deprecated Summary
LanguageArgument Defines an argument handler to accept a language.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal