forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Zend_Currency-Additional.xml
135 lines (109 loc) · 5.28 KB
/
Zend_Currency-Additional.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?xml version="1.0" encoding="utf-8"?>
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="zend.currency.additional"><info><title>Additional informations on Zend_Currency</title></info>
<section xml:id="zend.currency.additional.informations"><info><title>Currency informations</title></info>
<para>
Sometimes it is necessary to get informations which are related to a currency.
<classname>Zend_Currency</classname> provides you with several methods to get this
informations. Available methods include the following:
</para>
<itemizedlist mark="opencircle">
<listitem>
<para>
<emphasis><methodname>getCurrencyList()</methodname></emphasis>: Returns a list
of all currencies which are used in the given region as array. Defaults to the
objects locale when no region has been given.
</para>
</listitem>
<listitem>
<para>
<emphasis><methodname>getLocale()</methodname></emphasis>: Returns the set
locale for the actual currency.
</para>
</listitem>
<listitem>
<para>
<emphasis><methodname>getName()</methodname></emphasis>: Returns the full name
for the actual currency. When there is no full name available for the actual
currency, it will return the abbreviation for it.
</para>
</listitem>
<listitem>
<para>
<emphasis><methodname>getRegionList()</methodname></emphasis>: Returns a list
of all regions where this currency is used as array. Defaults to the objects
currency when no currency has been given.
</para>
</listitem>
<listitem>
<para>
<emphasis><methodname>getService()</methodname></emphasis>: Returns the set
exchange service object for the actual currency.
</para>
</listitem>
<listitem>
<para>
<emphasis><methodname>getShortName()</methodname></emphasis>: Returns the
abbreviation for the actual currency.
</para>
</listitem>
<listitem>
<para>
<emphasis><methodname>getSymbol()</methodname></emphasis>: Returns the currency
sign for the currency. When the currency has no symbol, then it will return the
abbreviation for it.
</para>
</listitem>
<listitem>
<para>
<emphasis><methodname>getValue()</methodname></emphasis>: Returns the set
value for the actual currency.
</para>
</listitem>
</itemizedlist>
<para>
Let's see some code snippets as example:
</para>
<programlisting language="php"><![CDATA[
$currency = new Zend_Currency();
var_dump($currency->getValue());
// returns 0
var_dump($currency->getRegionList());
// could return an array with all regions where USD is used
var_dump($currency->getRegionList('EUR'));
// returns an array with all regions where EUR is used
var_dump($currency->getName());
// could return 'US Dollar'
var_dump($currency->getName('EUR'));
// returns 'Euro'
]]></programlisting>
<para>
As you can see, several methods allow to use additional parameters to override the
actual object to get informations for other currencies. Omitting this parameters will
return informations from the actual set currency.
</para>
</section>
<section xml:id="zend.currency.additional.cache"><info><title>Currency Performance Optimization</title></info>
<para>
<classname>Zend_Currency</classname>'s performance can be optimized using
<classname>Zend_Cache</classname>. The static method
<methodname>Zend_Currency::setCache($cache)</methodname> accepts one option: a
<classname>Zend_Cache</classname> adapter. If the cache adapter is set, the localization
data which is used by <classname>Zend_Currency</classname> will be cached. Additionally
there are some static methods for manipulating the cache:
<methodname>getCache()</methodname>, <methodname>hasCache()</methodname>,
<methodname>clearCache()</methodname> and <methodname>removeCache()</methodname>.
</para>
<example xml:id="zend.currency.usage.cache.example"><info><title>Caching currencies</title></info>
<programlisting language="php"><![CDATA[
// creating a cache object
$cache = Zend_Cache::factory('Core',
'File',
array('lifetime' => 120,
'automatic_serialization' => true),
array('cache_dir'
=> dirname(__FILE__) . '/_files/'));
Zend_Currency::setCache($cache);
]]></programlisting>
</example>
</section>
</section>