listLanguages example

/** * Returns the available rendering strategies for language-aware entities. * * @return array * An array of available entity row renderers keyed by renderer identifiers. */
  protected function buildRenderingLanguageOptions() {
    // @todo Consider making these plugins. See     // https://www.drupal.org/node/2173811.     // Pass the current rendering language (in this case a one element array) so     // is not lost when there are language configuration changes.     return $this->listLanguages(LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED | PluginBase::INCLUDE_ENTITY, [$this->getOption('rendering_language')]);
  }

  /** * Returns whether the base table is of a translatable entity type. * * @return bool * TRUE if the base table is of a translatable entity type, FALSE otherwise. */
  protected function isBaseTableTranslatable() {
    if ($entity_type = $this->view->getBaseEntityType()) {
      return $entity_type->isTranslatable();
    }
/** * 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');
  }

}

  }

  /** * {@inheritdoc} */
  public function getValueOptions() {
    if (!isset($this->valueOptions)) {
      $this->valueTitle = $this->t('Language');
      // Pass the current values so options that are already selected do not get       // lost when there are changes in the language configuration.       $this->valueOptions = $this->listLanguages(LanguageInterface::STATE_ALL | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED, array_keys($this->value));
    }
    return $this->valueOptions;
  }

  /** * {@inheritdoc} */
  public function query() {
    // Don't filter by language in case the site is not multilingual, because     // there is no point in doing so.     if (!$this->languageManager->isMultilingual()) {
      
Home | Imprint | This part of the site doesn't use cookies.