You are here

class FullLanguageManager in Flags 8

Hierarchy

Expanded class hierarchy of FullLanguageManager

1 string reference to 'FullLanguageManager'
flags.services.yml in ./flags.services.yml
flags.services.yml
1 service uses FullLanguageManager
flags.language_helper in ./flags.services.yml
Drupal\flags\FullLanguageManager

File

src/FullLanguageManager.php, line 12

Namespace

Drupal\flags
View source
class FullLanguageManager implements FullLanguageManagerInterface {

  /**
   * @var ConfigurableLanguageManagerInterface
   */
  protected $languageManager;

  /**
   * @var ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * FullLanguageManager constructor.
   *
   * @param \Drupal\Core\Language\LanguageManager $languageManager
   * @param \Drupal\Core\Config\ConfigFactoryInterface
   */
  public function __construct(LanguageManagerInterface $languageManager, ConfigFactoryInterface $configFactory) {
    $this->languageManager = $languageManager;
    $this->configFactory = $configFactory;
  }

  /**
   * {@inheritdoc}
   */
  public function getAllDefinedLanguages() {

    // Get list of all configured languages.
    $languages = [];

    // See Drupal\language\ConfigurableLanguageManager::getLanguages() for details
    $predefined = LanguageManager::getStandardLanguageList();
    foreach ($predefined as $key => $value) {
      $languages[$key] = new TranslatableMarkup($value[0]);
    }
    $config_ids = $this->configFactory
      ->listAll('language.entity.');
    foreach ($this->configFactory
      ->loadMultiple($config_ids) as $config) {
      $data = $config
        ->get();
      $languages[$data['id']] = new TranslatableMarkup($data['label']);
    }
    asort($languages);
    return $languages;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FullLanguageManager::$configFactory protected property
FullLanguageManager::$languageManager protected property
FullLanguageManager::getAllDefinedLanguages public function Returns list of ALL languages including predefined and configured. Overrides FullLanguageManagerInterface::getAllDefinedLanguages
FullLanguageManager::__construct public function FullLanguageManager constructor.