8.3. Migrating from Previous Versions

The API of Zend_Currency has changed in the past to increase the usability. If you started using Zend_Currency with a version which is mentioned in this chapter follow the guidelines below to migrate your scripts to the new API.

8.3.1. Migrating from 1.0.2 to 1.0.3 or newer

Creating an object of Zend_Currency has become simpler. You now do not longer have to give a script or set it to null. The optional script parameter is now a option which can be set through the setFormat method.

<?php
$currency = new Zend_Currency($currency, $locale);
        

The setFormat method takes now an array of options which can be set. This options are set permanent and override all previous set values. Also a new option 'precision' has been integrated. The following options has been integrated:

  • position: Replacement for the old 'rules' parameter.

    script: Replacement for the old 'script' parameter.

    format: Replacement for the old 'locale' parameter which does not set new currencies but only the number format.

    display: Replacement for the old 'rules' parameter.

    precision: New parameter.

    name: Replacement for the ole 'rules' parameter. Sets the full currencies name.

    currency: New parameter.

    symbol: New parameter.

<?php
$currency->setFormat(array $options);
        

The toCurrency() method does no longer support the optional 'script' and 'locale' parameters. Instead it takes an options array which can contain the same keys as for the setFormat method.

<?php
$currency->toCurrency($value, array $options);
        

The methods getSymbol(), getShortName(), getName(), getRegionList() and getCurrencyList() are no longer static and can be called from within the object. They return the set values of the object if no parameter has been set.

    Поддержать сайт на родительском проекте КГБ