CurrencyFormatter.php in Price 2.0.x
File
src/CurrencyFormatter.php
View source
<?php
namespace Drupal\price;
use CommerceGuys\Intl\Currency\CurrencyRepositoryInterface;
use CommerceGuys\Intl\Formatter\CurrencyFormatter as ExternalCurrencyFormatter;
use CommerceGuys\Intl\NumberFormat\NumberFormatRepositoryInterface;
class CurrencyFormatter extends ExternalCurrencyFormatter {
public function __construct(NumberFormatRepositoryInterface $number_format_repository, CurrencyRepositoryInterface $currency_repository, CurrentLocaleInterface $current_locale) {
$debug = TRUE;
$default_options = [
'locale' => $current_locale
->getLocale()
->getLocaleCode(),
'maximum_fraction_digits' => 6,
'rounding_mode' => 'none',
];
parent::__construct($number_format_repository, $currency_repository, $default_options);
}
}
Classes
Name |
Description |
CurrencyFormatter |
Extends the commerceguys/intl CurrencyFormatter to provide better defaults. |