h4kuna/exchange-nette

v0.5.1 2024-09-05 07:54 UTC

This package is auto-updated.

Last update: 2024-09-16 06:49:21 UTC


README

Downloads this Month Latest Stable Version Coverage Status Total Downloads License

这个库是Nette框架的扩展,也是Exchange的扩展。

安装

通过composer简单安装

composer require h4kuna/exchange-nette

可选依赖项

composer require h4kuna/exchange-nette guzzlehttp/guzzle malkusch/lock nette/application nette/caching

注册

第一步是注册扩展并设置tempDir。

extensions:
    exchangeExtension: h4kuna\Exchange\DI\ExchangeExtension 

扩展已经准备好使用,其他配置是可选的。默认定义了三种货币CZK、EUR和USD。货币格式默认由h4kuna/number-format定义,其中包含文档。

配置

货币读取的格式选项请参考h4kuna/number-format

exchangeExtension:
    currencies:
            czk: # upper / lower code of currency is not important
                decimals: 3
                decimalPoint: '.'
                thousandsSeparator: ','
                zeroIsEmpty: true
                emptyValue: '-'
                zeroClear: true
                mask: '1U'
                showUnitIfEmpty: false 
                nbsp: true
                unit: 
                round: h4kuna\Format\Number\Round::BY_CEIL
                
            usd:
                unit: '$'
            gbp: [] # use default format 
            foo: null # disable
    driver: # string class of h4kuna\Exchange\Driver\Driver default is Cnb\Day
    session: false # save info about currencies to session, default is only to cookie 
    vat: 21 # add number like percent
    strict: true # default enabled, download only defined currencies, example: ['CZK', 'EUR']
    defaultFormat: null # how format currency if format is not defined, value is array like above "currencies.czk" 
    managerParameter: 'currency' # is parameter for query, cookie and session if is available
    tempDir: %tempDir% # temporary directory for cache
    filters: # extension define frour filter for latte, you can rename
        currency: currency
        currencyTo: currencyTo
        vat: vat
        vatTo: vatTo

Latte

现在我们有四个新的过滤器。

{=100|currency}
{=100|vat}
{=100|currencyTo}
{=100|vatTo}

请求

创建带有参数货币和更改值的URL并检查cookie。

/?currency=USD