LanguageDefault.php 1.33 KB
Newer Older
1 2 3 4 5
<?php

namespace Drupal\Core\Language;

/**
6
 * Provides a simple get and set wrapper to the default language object.
7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * The default language must be provided without dependencies since it is both
 * configured and a dependency of the configuration system. The LanguageDefault
 * object is a container service. The default values are stored on the container
 * by \Drupal\Core\DrupalKernel::buildContainer(). This allows services to
 * override this parameter in a ServiceProvider, for example,
 * \Drupal\language\LanguageServiceProvider::alter().
 */
class LanguageDefault {

  /**
   * The default language.
   *
20
   * @var \Drupal\Core\Language\LanguageInterface
21 22 23 24 25 26
   */
  protected $language;

  /**
   * Constructs the default language object.
   *
27 28
   * @param array $values
   *   The properties used to construct the default language.
29
   */
30 31
  public function __construct(array $values) {
    $this->set(new Language($values));
32 33 34 35 36
  }

  /**
   * Gets the default language.
   *
37
   * @return \Drupal\Core\Language\LanguageInterface
38 39 40 41 42 43 44 45 46
   *   The default language.
   */
  public function get() {
    return $this->language;
  }

  /**
   * Sets the default language.
   *
47
   * @param \Drupal\Core\Language\LanguageInterface $language
48 49
   *   The default language.
   */
50
  public function set(LanguageInterface $language) {
51 52 53 54
    $this->language = $language;
  }

}