class CurrencyViewHelper extends AbstractLocaleAwareViewHelper (View source)

Formats a given float to a currency representation.

= Examples =

123.456 ``` 123,46 54321 ``` 54,321.00 $ {someNumber -> f:format.currency(thousandsSeparator: ',', currencySign: '€')} ``` 54,321,00 € (depending on the value of {someNumber}) {someNumber -> f:format.currency(currencySign: '€', forceLocale: true)} ``` 54.321,00 € (depending on the value of {someNumber} and the current locale) {someNumber -> f:format.currency(currencySign: 'EUR', forceLocale: 'de_DE')} ``` 54.321,00 EUR (depending on the value of {someNumber}) {someNumber -> f:format.currency(currencySign: '€', prependCurrency: 'true')} ``` € 54.321,00 (depending on the value of {someNumber}) {someNumber -> f:format.currency(currencySign: '€', separateCurrency: 'false', decimals: '0')} ``` 54.321€ (depending on the value of {someNumber}) Note: This ViewHelper is intended to help you with formatting numbers into monetary units. Complex calculations and/or conversions should be done before the number is passed. Also be aware that if the ``locale`` is set, all arguments except for the currency sign (which then becomes mandatory) are ignored and the CLDR (Common Locale Data Repository) is used for formatting. Fore more information about localization see section ``Internationalization & Localization Framework`` in the Flow documentation. Additionally, if ``currencyCode`` is set, rounding and decimal digits are replaced by the rules for the respective currency (e.g. JPY never has decimal digits, CHF is rounded using 5 decimals.)

Properties

protected ControllerContext $controllerContext

Controller Context to use

from  AbstractViewHelper
protected ObjectManagerInterface $objectManager from  AbstractViewHelper
protected LoggerInterface $logger from  AbstractViewHelper
protected Service $localizationService from  AbstractLocaleAwareViewHelper
protected NumberFormatter $numberFormatter

Methods

void
setRenderingContext(RenderingContextInterface $renderingContext)

No description

void
injectObjectManager(ObjectManagerInterface $objectManager)

No description

void
injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

AbstractViewHelper
registerArgument(string $name, string $type, string $description, bool $required = false, mixed $defaultValue = null, bool|null $escape = null)

Register a new argument. Call this method from your ViewHelper subclass inside the initializeArguments() method.

AbstractViewHelper
overrideArgument(string $name, string $type, string $description, bool $required = false, mixed $defaultValue = null, bool|null $escape = null)

Overrides a registered argument. Call this method from your ViewHelper subclass inside the initializeArguments() method if you want to override a previously registered argument.

injectLocalizationService(Service $localizationService)

No description

getLocale()

Get the locale to use for all locale specific functionality.

void
initializeArguments()

Initialize the arguments.

string
render()

No description

Details

void setRenderingContext(RenderingContextInterface $renderingContext)

No description

Parameters

RenderingContextInterface $renderingContext

Return Value

void

void injectObjectManager(ObjectManagerInterface $objectManager)

No description

Parameters

ObjectManagerInterface $objectManager

Return Value

void

void injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

Parameters

LoggerInterface $logger

Return Value

void

protected AbstractViewHelper registerArgument(string $name, string $type, string $description, bool $required = false, mixed $defaultValue = null, bool|null $escape = null)

Register a new argument. Call this method from your ViewHelper subclass inside the initializeArguments() method.

This exists only to throw our own exception!

Parameters

string $name

Name of the argument

string $type

Type of the argument

string $description

Description of the argument

bool $required

If true, argument is required. Defaults to false.

mixed $defaultValue

Default value of argument

bool|null $escape

Can be toggled to TRUE to force escaping of variables and inline syntax passed as argument value.

Return Value

AbstractViewHelper

$this, to allow chaining.

Exceptions

Exception

protected AbstractViewHelper overrideArgument(string $name, string $type, string $description, bool $required = false, mixed $defaultValue = null, bool|null $escape = null)

Overrides a registered argument. Call this method from your ViewHelper subclass inside the initializeArguments() method if you want to override a previously registered argument.

This exists only to throw our own exception!

Parameters

string $name

Name of the argument

string $type

Type of the argument

string $description

Description of the argument

bool $required

If true, argument is required. Defaults to false.

mixed $defaultValue

Default value of argument

bool|null $escape

Can be toggled to TRUE to force escaping of variables and inline syntax passed as argument value.

Return Value

AbstractViewHelper

$this, to allow chaining.

Exceptions

Exception

See also

registerArgument()

bool isEscapingInterceptorEnabled()

No description

Return Value

bool

__construct()

Constructor

injectLocalizationService(Service $localizationService)

No description

Parameters

Service $localizationService

protected Locale getLocale()

Get the locale to use for all locale specific functionality.

Return Value

Locale

The locale to use or NULL if locale should not be used

Exceptions

InvalidVariableException

void initializeArguments()

Initialize the arguments.

Return Value

void

string render()

No description

Return Value

string

the formatted amount.

Exceptions

InvalidVariableException
Exception