public function CurrencyFormatter::__construct in Price 8
Same name and namespace in other branches
- 3.x src/CurrencyFormatter.php \Drupal\price\CurrencyFormatter::__construct()
- 2.0.x src/CurrencyFormatter.php \Drupal\price\CurrencyFormatter::__construct()
- 2.x src/CurrencyFormatter.php \Drupal\price\CurrencyFormatter::__construct()
- 3.0.x src/CurrencyFormatter.php \Drupal\price\CurrencyFormatter::__construct()
Constructs a new CurrencyFormatter object.
Parameters
\CommerceGuys\Intl\NumberFormat\NumberFormatRepositoryInterface $number_format_repository: The number format repository.
\CommerceGuys\Intl\Currency\CurrencyRepositoryInterface $currency_repository: The currency repository.
\Drupal\price\CurrentLocaleInterface $current_locale: The current locale.
File
- src/
CurrencyFormatter.php, line 27
Class
- CurrencyFormatter
- Extends the commerceguys/intl CurrencyFormatter to provide better defaults.
Namespace
Drupal\priceCode
public function __construct(NumberFormatRepositoryInterface $number_format_repository, CurrencyRepositoryInterface $currency_repository, CurrentLocaleInterface $current_locale) {
$default_options = [
'locale' => $current_locale
->getLocale()
->getLocaleCode(),
// Show prices as-is. All digits (storage max is 6), non-rounded.
'maximum_fraction_digits' => 6,
'rounding_mode' => 'none',
];
parent::__construct($number_format_repository, $currency_repository, $default_options);
}