flagbit/currency-bundle

FlagbitCurrencyBundle for the Symfony Framework

Installs: 1 488

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 22

Forks: 0

Open Issues: 1

Type:symfony-bundle

3.0.0 2018-07-23 08:40 UTC

This package is auto-updated.

Last update: 2021-07-08 15:07:28 UTC


README

Build Status SensioLabsInsight License Scrutinizer Code Quality

About

The FlagbitCurrencyBundle provides basic functions to display currency symbols and names.

Configuration

You can set your default currency. The bundle defaults to EUR. Currency code has to be UPPERCASE.

flagbit_currency:
    default_currency: EUR

Services

Fetch the global default currency.

$container->get('flagbit_currency')->getDefaultCurrency(); // EUR

Fetch the currency name. Actual output depends on your locale set.

$container->get('flagbit_currency')->getCurrencyName(); // Euro
$container->get('flagbit_currency')->getCurrencyName('EUR'); // Euro
$container->get('flagbit_currency')->getCurrencyName('USD'); // US Dollar

Fetch the symbol for the default currency or a given currency.

$container->get('flagbit_currency')->getCurrencySymbol(); // €
$container->get('flagbit_currency')->getCurrencySymbol('EUR'); // €
$container->get('flagbit_currency')->getCurrencySymbol('USD'); // $

It is recommended, that you don't fetch a service directly from a container and use dependency injection instead.

Twig

Functions

currency_name

Fetch the currency name. Actual output depends on your locale set.

{{ currency_name() }} {# example output: Euro #}
{{ currency_name('EUR') }} {# example output: Euro #}
{{ currency_name('USD') }} {# example output: US Dollar #}

curreny_symbol

Fetch the symbol for the default currency or a given currency.

{{ currency_symbol() }} {# example output: € #}
{{ currency_symbol('CHF') }} {# example output: CHF #}
{{ currency_symbol('EUR') }} {# example output: € #}

Globals

The default currency code is available as variable.

{{ currency.default }} {# example output: EUR #}