filterLanguages example

      // middle of importing language configuration entities, the defaults are       // always present.       $config_ids = $this->configFactory->listAll('language.entity.');
      foreach ($this->configFactory->loadMultiple($config_ids) as $config) {
        $data = $config->get();
        $data['name'] = $data['label'];
        $languages[$data['id']] = new Language($data);
      }
      Language::sort($languages);

      // Filter the full list of languages based on the value of $flags.       $this->languages[$static_cache_id][$flags] = $this->filterLanguages($languages$flags);
    }

    return $this->languages[$static_cache_id][$flags];
  }

  /** * {@inheritdoc} */
  public function getNativeLanguages() {
    $languages = $this->getLanguages(LanguageInterface::STATE_CONFIGURABLE);
    $natives = [];

    
public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) {
    $static_cache_id = $this->getCurrentLanguage()->getId();
    if (!isset($this->languages[$static_cache_id][$flags])) {
      // If this language manager is used, there are no configured languages.       // The default language and locked languages comprise the full language       // list.       $default = $this->getDefaultLanguage();
      $languages = [$default->getId() => $default];
      $languages += $this->getDefaultLockedLanguages($default->getWeight());

      // Filter the full list of languages based on the value of $flags.       $this->languages[$static_cache_id][$flags] = $this->filterLanguages($languages$flags);
    }
    return $this->languages[$static_cache_id][$flags];
  }

  /** * {@inheritdoc} */
  public function getNativeLanguages() {
    // In a language unaware site we don't have translated languages.     return $this->getLanguages();
  }

  
Home | Imprint | This part of the site doesn't use cookies.