You are here

public function NumberFormatter::__construct in Price 8

Same name and namespace in other branches
  1. 3.x src/NumberFormatter.php \Drupal\price\NumberFormatter::__construct()
  2. 2.0.x src/NumberFormatter.php \Drupal\price\NumberFormatter::__construct()
  3. 2.x src/NumberFormatter.php \Drupal\price\NumberFormatter::__construct()
  4. 3.0.x src/NumberFormatter.php \Drupal\price\NumberFormatter::__construct()

Constructs a new NumberFormatter object.

Parameters

\CommerceGuys\Intl\NumberFormat\NumberFormatRepositoryInterface $number_format_repository: The number format repository.

\Drupal\price\CurrentLocaleInterface $current_locale: The current locale.

File

src/NumberFormatter.php, line 24

Class

NumberFormatter
Extends the commerceguys/intl NumberFormatter to provide better defaults.

Namespace

Drupal\price

Code

public function __construct(NumberFormatRepositoryInterface $number_format_repository, CurrentLocaleInterface $current_locale) {
  $default_options = [
    'locale' => $current_locale
      ->getLocale()
      ->getLocaleCode(),
  ];
  parent::__construct($number_format_repository, $default_options);
}