DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / Financial / DAO / Currency.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Financial/Currency.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:0347ed61e0dc585d250a83f9fa162f2d)
10 */
11
12 /**
13 * Database access object for the Currency entity.
14 */
15 class CRM_Financial_DAO_Currency extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.7';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_currency';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = TRUE;
32
33 /**
34 * Currency Id
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Currency Name
42 *
43 * @var string
44 */
45 public $name;
46
47 /**
48 * Currency Symbol
49 *
50 * @var string
51 */
52 public $symbol;
53
54 /**
55 * Numeric currency code
56 *
57 * @var string
58 */
59 public $numeric_code;
60
61 /**
62 * Full currency name
63 *
64 * @var string
65 */
66 public $full_name;
67
68 /**
69 * Class constructor.
70 */
71 public function __construct() {
72 $this->__table = 'civicrm_currency';
73 parent::__construct();
74 }
75
76 /**
77 * Returns localized title of this entity.
78 *
79 * @param bool $plural
80 * Whether to return the plural version of the title.
81 */
82 public static function getEntityTitle($plural = FALSE) {
83 return $plural ? ts('Currencies') : ts('Currency');
84 }
85
86 /**
87 * Returns all the column names of this table
88 *
89 * @return array
90 */
91 public static function &fields() {
92 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
93 Civi::$statics[__CLASS__]['fields'] = [
94 'id' => [
95 'name' => 'id',
96 'type' => CRM_Utils_Type::T_INT,
97 'title' => ts('Currency ID'),
98 'description' => ts('Currency Id'),
99 'required' => TRUE,
100 'where' => 'civicrm_currency.id',
101 'table_name' => 'civicrm_currency',
102 'entity' => 'Currency',
103 'bao' => 'CRM_Financial_DAO_Currency',
104 'localizable' => 0,
105 'add' => '1.7',
106 ],
107 'name' => [
108 'name' => 'name',
109 'type' => CRM_Utils_Type::T_STRING,
110 'title' => ts('Currency'),
111 'description' => ts('Currency Name'),
112 'maxlength' => 64,
113 'size' => CRM_Utils_Type::BIG,
114 'import' => TRUE,
115 'where' => 'civicrm_currency.name',
116 'export' => TRUE,
117 'table_name' => 'civicrm_currency',
118 'entity' => 'Currency',
119 'bao' => 'CRM_Financial_DAO_Currency',
120 'localizable' => 0,
121 'html' => [
122 'type' => 'Text',
123 ],
124 'add' => '1.7',
125 ],
126 'symbol' => [
127 'name' => 'symbol',
128 'type' => CRM_Utils_Type::T_STRING,
129 'title' => ts('Currency Symbol'),
130 'description' => ts('Currency Symbol'),
131 'maxlength' => 8,
132 'size' => CRM_Utils_Type::EIGHT,
133 'where' => 'civicrm_currency.symbol',
134 'table_name' => 'civicrm_currency',
135 'entity' => 'Currency',
136 'bao' => 'CRM_Financial_DAO_Currency',
137 'localizable' => 0,
138 'html' => [
139 'type' => 'Text',
140 ],
141 'add' => '1.7',
142 ],
143 'numeric_code' => [
144 'name' => 'numeric_code',
145 'type' => CRM_Utils_Type::T_STRING,
146 'title' => ts('Currency Numeric Code'),
147 'description' => ts('Numeric currency code'),
148 'maxlength' => 3,
149 'size' => CRM_Utils_Type::FOUR,
150 'import' => TRUE,
151 'where' => 'civicrm_currency.numeric_code',
152 'export' => TRUE,
153 'table_name' => 'civicrm_currency',
154 'entity' => 'Currency',
155 'bao' => 'CRM_Financial_DAO_Currency',
156 'localizable' => 0,
157 'add' => '1.9',
158 ],
159 'full_name' => [
160 'name' => 'full_name',
161 'type' => CRM_Utils_Type::T_STRING,
162 'title' => ts('Full Currency Name'),
163 'description' => ts('Full currency name'),
164 'maxlength' => 64,
165 'size' => CRM_Utils_Type::BIG,
166 'where' => 'civicrm_currency.full_name',
167 'table_name' => 'civicrm_currency',
168 'entity' => 'Currency',
169 'bao' => 'CRM_Financial_DAO_Currency',
170 'localizable' => 0,
171 'html' => [
172 'type' => 'Text',
173 ],
174 'add' => '1.9',
175 ],
176 ];
177 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
178 }
179 return Civi::$statics[__CLASS__]['fields'];
180 }
181
182 /**
183 * Return a mapping from field-name to the corresponding key (as used in fields()).
184 *
185 * @return array
186 * Array(string $name => string $uniqueName).
187 */
188 public static function &fieldKeys() {
189 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
190 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
191 }
192 return Civi::$statics[__CLASS__]['fieldKeys'];
193 }
194
195 /**
196 * Returns the names of this table
197 *
198 * @return string
199 */
200 public static function getTableName() {
201 return self::$_tableName;
202 }
203
204 /**
205 * Returns if this table needs to be logged
206 *
207 * @return bool
208 */
209 public function getLog() {
210 return self::$_log;
211 }
212
213 /**
214 * Returns the list of fields that can be imported
215 *
216 * @param bool $prefix
217 *
218 * @return array
219 */
220 public static function &import($prefix = FALSE) {
221 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'currency', $prefix, []);
222 return $r;
223 }
224
225 /**
226 * Returns the list of fields that can be exported
227 *
228 * @param bool $prefix
229 *
230 * @return array
231 */
232 public static function &export($prefix = FALSE) {
233 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'currency', $prefix, []);
234 return $r;
235 }
236
237 /**
238 * Returns the list of indices
239 *
240 * @param bool $localize
241 *
242 * @return array
243 */
244 public static function indices($localize = TRUE) {
245 $indices = [];
246 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
247 }
248
249 }