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