[MANUAL] English:
[zend.git] / documentation / manual / en / module_specs / Zend_Currency-Additional.xml
blobcfb7b25fe514bd6d0043bf91c724c50e53ed840e
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- Reviewed: no -->
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>
9         <para>
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:
13         </para>
15         <itemizedlist mark='opencircle'>
16             <listitem>
17                 <para>
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.
21                 </para>
22             </listitem>
24             <listitem>
25                 <para>
26                     <emphasis><methodname>getLocale()</methodname></emphasis>: Returns the set
27                     locale for the actual currency.
28                 </para>
29             </listitem>
31             <listitem>
32                 <para>
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.
36                 </para>
37             </listitem>
39             <listitem>
40                 <para>
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.
44                 </para>
45             </listitem>
47             <listitem>
48                 <para>
49                     <emphasis><methodname>getService()</methodname></emphasis>: Returns the set
50                     exchange service object for the actual currency.
51                 </para>
52             </listitem>
54             <listitem>
55                 <para>
56                     <emphasis><methodname>getShortName()</methodname></emphasis>: Returns the
57                     abbreviation for the actual currency.
58                 </para>
59             </listitem>
61             <listitem>
62                 <para>
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
65                     abbreviation for it.
66                 </para>
67             </listitem>
69             <listitem>
70                 <para>
71                     <emphasis><methodname>getValue()</methodname></emphasis>: Returns the set
72                     value for the actual currency.
73                 </para>
74             </listitem>
75         </itemizedlist>
77         <para>
78             Let's see some code snippets as example:
79         </para>
81         <programlisting language="php"><![CDATA[
82 $currency = new Zend_Currency();
84 var_dump($currency->getValue());
85 // returns 0
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'));
97 // returns 'Euro'
98 ]]></programlisting>
100         <para>
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.
104         </para>
105     </sect2>
107     <sect2 id="zend.currency.additional.cache">
108         <title>Currency Performance Optimization</title>
110         <para>
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>.
119         </para>
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',
127                              'File',
128                              array('lifetime' => 120,
129                                    'automatic_serialization' => true),
130                              array('cache_dir'
131                                        => dirname(__FILE__) . '/_files/'));
132 Zend_Currency::setCache($cache);
133 ]]></programlisting>
134         </example>
135     </sect2>
136 </sect1>