public function Language::__construct

Language constructor builds the default language object.

Parameters

array $options: The properties used to construct the language.

File

drupal/core/lib/Drupal/Core/Language/Language.php, line 119
Definition of Drupal\Core\Language\Language.

Class

Language
An object containing the information for an interface language.

Namespace

Drupal\Core\Language

Code

public function __construct(array $options = array()) {

  // Set all the provided properties for the language.
  foreach ($options as $name => $value) {
    $this->{$name} = $value;
  }

  // If some options were not set, set sane defaults of a predefined language.
  if (!isset($options['name']) || !isset($options['direction'])) {
    $predefined = LanguageManager::getStandardLanguageList();
    if (isset($predefined[$this->langcode])) {
      if (!isset($options['name'])) {
        $this->name = $predefined[$this->langcode][0];
      }
      if (!isset($options['direction']) && isset($predefined[$this->langcode][2])) {
        $this->direction = $predefined[$this->langcode][2];
      }
    }
  }
}