use configured language for non-twig invoice templates (#1924)
This commit is contained in:
@@ -9,24 +9,19 @@
|
||||
|
||||
namespace App\Invoice;
|
||||
|
||||
use App\Twig\DateExtensions;
|
||||
use App\Twig\LocaleExtensions;
|
||||
use App\Configuration\LanguageFormattings;
|
||||
use App\Utils\LocaleFormatter;
|
||||
|
||||
final class DefaultInvoiceFormatter implements InvoiceFormatter
|
||||
{
|
||||
/**
|
||||
* @var DateExtensions
|
||||
* @var LocaleFormatter
|
||||
*/
|
||||
private $dateExtension;
|
||||
/**
|
||||
* @var LocaleExtensions
|
||||
*/
|
||||
private $extension;
|
||||
private $formatter;
|
||||
|
||||
public function __construct(DateExtensions $dateExtension, LocaleExtensions $extensions)
|
||||
public function __construct(LanguageFormattings $formats, string $locale)
|
||||
{
|
||||
$this->dateExtension = $dateExtension;
|
||||
$this->extension = $extensions;
|
||||
$this->formatter = new LocaleFormatter($formats, $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,7 +30,7 @@ final class DefaultInvoiceFormatter implements InvoiceFormatter
|
||||
*/
|
||||
public function getFormattedDateTime(\DateTime $date)
|
||||
{
|
||||
return $this->dateExtension->dateShort($date);
|
||||
return $this->formatter->dateShort($date);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +39,7 @@ final class DefaultInvoiceFormatter implements InvoiceFormatter
|
||||
*/
|
||||
public function getFormattedTime(\DateTime $date)
|
||||
{
|
||||
return $this->dateExtension->time($date);
|
||||
return $this->formatter->time($date);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +48,7 @@ final class DefaultInvoiceFormatter implements InvoiceFormatter
|
||||
*/
|
||||
public function getFormattedMonthName(\DateTime $date)
|
||||
{
|
||||
return $this->dateExtension->monthName($date);
|
||||
return $this->formatter->monthName($date);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,7 +59,7 @@ final class DefaultInvoiceFormatter implements InvoiceFormatter
|
||||
*/
|
||||
public function getFormattedMoney($amount, ?string $currency, bool $withCurrency = true)
|
||||
{
|
||||
return $this->extension->money($amount, $currency, $withCurrency);
|
||||
return $this->formatter->money($amount, $currency, $withCurrency);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +68,7 @@ final class DefaultInvoiceFormatter implements InvoiceFormatter
|
||||
*/
|
||||
public function getFormattedDuration($seconds)
|
||||
{
|
||||
return $this->extension->duration($seconds);
|
||||
return $this->formatter->duration($seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,11 +77,11 @@ final class DefaultInvoiceFormatter implements InvoiceFormatter
|
||||
*/
|
||||
public function getFormattedDecimalDuration($seconds)
|
||||
{
|
||||
return $this->extension->durationDecimal($seconds);
|
||||
return $this->formatter->durationDecimal($seconds);
|
||||
}
|
||||
|
||||
public function getCurrencySymbol(string $currency): string
|
||||
{
|
||||
return $this->extension->currency($currency);
|
||||
return $this->formatter->currency($currency);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user