You are here

public function NumberFormatter::__construct in Physical Fields 8

Constructs a new NumberFormatter object.

Parameters

\Drupal\Core\Language\LanguageManagerInterface $language_manager: The language manager.

File

src/NumberFormatter.php, line 37

Class

NumberFormatter
Default number formatter.

Namespace

Drupal\physical

Code

public function __construct(LanguageManagerInterface $language_manager) {
  if (extension_loaded('intl')) {
    $language = $language_manager
      ->getConfigOverrideLanguage() ?: $language_manager
      ->getCurrentLanguage();
    $this->numberFormatter = new \NumberFormatter($language
      ->getId(), \NumberFormatter::DECIMAL);
  }
}