From: Marcel Werk Date: Wed, 13 Nov 2024 13:14:48 +0000 (+0100) Subject: Add column renderer for currencies X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=55ca66fe6d22984343b5c12c803909780e3646d3;p=GitHub%2FWoltLab%2FWCF.git Add column renderer for currencies --- diff --git a/wcfsetup/install/files/lib/system/gridView/renderer/CurrencyColumnRenderer.class.php b/wcfsetup/install/files/lib/system/gridView/renderer/CurrencyColumnRenderer.class.php new file mode 100644 index 0000000000..6c07c28cd0 --- /dev/null +++ b/wcfsetup/install/files/lib/system/gridView/renderer/CurrencyColumnRenderer.class.php @@ -0,0 +1,38 @@ + + * @since 6.2 + */ +class CurrencyColumnRenderer extends AbstractColumnRenderer +{ + public function __construct( + private readonly string $currency, + ) {} + + #[\Override] + public function render(mixed $value, mixed $context = null): string + { + return \number_format( + \round($value, 2), + 2, + WCF::getLanguage()->get('wcf.global.decimalPoint'), + WCF::getLanguage()->get('wcf.global.thousandsSeparator') + ) . ' ' . StringUtil::encodeHTML($this->currency); + } + + #[\Override] + public function getClasses(): string + { + return 'gridView__column--digits'; + } +}