1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.currency.additional">
4 <title>Additional informations on Zend_Currency</title>
6 <sect2 id="zend.currency.additional.informations">
7 <title>Currency informations</title>
10 Sometimes it is necessary to get informations which are related to a currency.
11 <classname>Zend_Currency</classname> provides you with several methods to get this
12 informations. Available methods include the following:
15 <itemizedlist mark='opencircle'>
18 <emphasis><methodname>getCurrencyList()</methodname></emphasis>: Returns a list
19 of all currencies which are used in the given region as array. Defaults to the
20 objects locale when no region has been given.
26 <emphasis><methodname>getLocale()</methodname></emphasis>: Returns the set
27 locale for the actual currency.
33 <emphasis><methodname>getName()</methodname></emphasis>: Returns the full name
34 for the actual currency. When there is no full name available for the actual
35 currency, it will return the abbreviation for it.
41 <emphasis><methodname>getRegionList()</methodname></emphasis>: Returns a list
42 of all regions where this currency is used as array. Defaults to the objects
43 currency when no currency has been given.
49 <emphasis><methodname>getService()</methodname></emphasis>: Returns the set
50 exchange service object for the actual currency.
56 <emphasis><methodname>getShortName()</methodname></emphasis>: Returns the
57 abbreviation for the actual currency.
63 <emphasis><methodname>getSymbol()</methodname></emphasis>: Returns the currency
64 sign for the currency. When the currency has no symbol, then it will return the
71 <emphasis><methodname>getValue()</methodname></emphasis>: Returns the set
72 value for the actual currency.
78 Let's see some code snippets as example:
81 <programlisting language="php"><![CDATA[
82 $currency = new Zend_Currency();
84 var_dump($currency->getValue());
87 var_dump($currency->getRegionList());
88 // could return an array with all regions where USD is used
90 var_dump($currency->getRegionList('EUR'));
91 // returns an array with all regions where EUR is used
93 var_dump($currency->getName());
94 // could return 'US Dollar'
96 var_dump($currency->getName('EUR'));
101 As you can see, several methods allow to use additional parameters to override the
102 actual object to get informations for other currencies. Omitting this parameters will
103 return informations from the actual set currency.
107 <sect2 id="zend.currency.additional.cache">
108 <title>Currency Performance Optimization</title>
111 <classname>Zend_Currency</classname>'s performance can be optimized using
112 <classname>Zend_Cache</classname>. The static method
113 <methodname>Zend_Currency::setCache($cache)</methodname> accepts one option: a
114 <classname>Zend_Cache</classname> adapter. If the cache adapter is set, the localization
115 data which is used by <classname>Zend_Currency</classname> will be cached. Additionally
116 there are some static methods for manipulating the cache:
117 <methodname>getCache()</methodname>, <methodname>hasCache()</methodname>,
118 <methodname>clearCache()</methodname> and <methodname>removeCache()</methodname>.
121 <example id="zend.currency.usage.cache.example">
122 <title>Caching currencies</title>
124 <programlisting language="php"><![CDATA[
125 // creating a cache object
126 $cache = Zend_Cache::factory('Core',
128 array('lifetime' => 120,
129 'automatic_serialization' => true),
131 => dirname(__FILE__) . '/_files/'));
132 Zend_Currency::setCache($cache);