Regenerate DAO files
[civicrm-core.git] / CRM / Core / DAO / Country.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Country.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:e5b8ae0961e387f04f4fa49cb92144cf)
10 */
11
12 /**
13 * Database access object for the Country entity.
14 */
15 class CRM_Core_DAO_Country extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_country';
25
26 /**
27 * Field to show when displaying a record.
28 *
29 * @var string
30 */
31 public static $_labelField = 'name';
32
33 /**
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
35 *
36 * @var bool
37 */
38 public static $_log = FALSE;
39
40 /**
41 * Country ID
42 *
43 * @var int
44 */
45 public $id;
46
47 /**
48 * Country Name
49 *
50 * @var string
51 */
52 public $name;
53
54 /**
55 * ISO Code
56 *
57 * @var string
58 */
59 public $iso_code;
60
61 /**
62 * National prefix to be used when dialing TO this country.
63 *
64 * @var string
65 */
66 public $country_code;
67
68 /**
69 * Foreign key to civicrm_address_format.id.
70 *
71 * @var int
72 */
73 public $address_format_id;
74
75 /**
76 * International direct dialing prefix from within the country TO another country
77 *
78 * @var string
79 */
80 public $idd_prefix;
81
82 /**
83 * Access prefix to call within a country to a different area
84 *
85 * @var string
86 */
87 public $ndd_prefix;
88
89 /**
90 * Foreign key to civicrm_worldregion.id.
91 *
92 * @var int
93 */
94 public $region_id;
95
96 /**
97 * Should state/province be displayed as abbreviation for contacts from this country?
98 *
99 * @var bool
100 */
101 public $is_province_abbreviated;
102
103 /**
104 * Is this Country active?
105 *
106 * @var bool
107 */
108 public $is_active;
109
110 /**
111 * Class constructor.
112 */
113 public function __construct() {
114 $this->__table = 'civicrm_country';
115 parent::__construct();
116 }
117
118 /**
119 * Returns localized title of this entity.
120 *
121 * @param bool $plural
122 * Whether to return the plural version of the title.
123 */
124 public static function getEntityTitle($plural = FALSE) {
125 return $plural ? ts('Countries') : ts('Country');
126 }
127
128 /**
129 * Returns foreign keys and entity references.
130 *
131 * @return array
132 * [CRM_Core_Reference_Interface]
133 */
134 public static function getReferenceColumns() {
135 if (!isset(Civi::$statics[__CLASS__]['links'])) {
136 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
137 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'address_format_id', 'civicrm_address_format', 'id');
138 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'region_id', 'civicrm_worldregion', 'id');
139 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
140 }
141 return Civi::$statics[__CLASS__]['links'];
142 }
143
144 /**
145 * Returns all the column names of this table
146 *
147 * @return array
148 */
149 public static function &fields() {
150 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
151 Civi::$statics[__CLASS__]['fields'] = [
152 'id' => [
153 'name' => 'id',
154 'type' => CRM_Utils_Type::T_INT,
155 'title' => ts('Country ID'),
156 'description' => ts('Country ID'),
157 'required' => TRUE,
158 'where' => 'civicrm_country.id',
159 'table_name' => 'civicrm_country',
160 'entity' => 'Country',
161 'bao' => 'CRM_Core_BAO_Country',
162 'localizable' => 0,
163 'html' => [
164 'type' => 'Number',
165 ],
166 'add' => '1.1',
167 ],
168 'name' => [
169 'name' => 'name',
170 'type' => CRM_Utils_Type::T_STRING,
171 'title' => ts('Country'),
172 'description' => ts('Country Name'),
173 'maxlength' => 64,
174 'size' => CRM_Utils_Type::BIG,
175 'import' => TRUE,
176 'where' => 'civicrm_country.name',
177 'headerPattern' => '/country/i',
178 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
179 'export' => TRUE,
180 'table_name' => 'civicrm_country',
181 'entity' => 'Country',
182 'bao' => 'CRM_Core_BAO_Country',
183 'localizable' => 0,
184 'add' => '1.1',
185 ],
186 'iso_code' => [
187 'name' => 'iso_code',
188 'type' => CRM_Utils_Type::T_STRING,
189 'title' => ts('Country ISO Code'),
190 'description' => ts('ISO Code'),
191 'maxlength' => 2,
192 'size' => CRM_Utils_Type::TWO,
193 'where' => 'civicrm_country.iso_code',
194 'table_name' => 'civicrm_country',
195 'entity' => 'Country',
196 'bao' => 'CRM_Core_BAO_Country',
197 'localizable' => 0,
198 'add' => '1.1',
199 ],
200 'country_code' => [
201 'name' => 'country_code',
202 'type' => CRM_Utils_Type::T_STRING,
203 'title' => ts('Country Phone Prefix'),
204 'description' => ts('National prefix to be used when dialing TO this country.'),
205 'maxlength' => 4,
206 'size' => CRM_Utils_Type::FOUR,
207 'where' => 'civicrm_country.country_code',
208 'table_name' => 'civicrm_country',
209 'entity' => 'Country',
210 'bao' => 'CRM_Core_BAO_Country',
211 'localizable' => 0,
212 'add' => '1.1',
213 ],
214 'address_format_id' => [
215 'name' => 'address_format_id',
216 'type' => CRM_Utils_Type::T_INT,
217 'title' => ts('Address Format ID'),
218 'description' => ts('Foreign key to civicrm_address_format.id.'),
219 'where' => 'civicrm_country.address_format_id',
220 'table_name' => 'civicrm_country',
221 'entity' => 'Country',
222 'bao' => 'CRM_Core_BAO_Country',
223 'localizable' => 0,
224 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
225 'html' => [
226 'label' => ts("Address Format"),
227 ],
228 'add' => '3.2',
229 ],
230 'idd_prefix' => [
231 'name' => 'idd_prefix',
232 'type' => CRM_Utils_Type::T_STRING,
233 'title' => ts('Outgoing Phone Prefix'),
234 'description' => ts('International direct dialing prefix from within the country TO another country'),
235 'maxlength' => 4,
236 'size' => CRM_Utils_Type::FOUR,
237 'where' => 'civicrm_country.idd_prefix',
238 'table_name' => 'civicrm_country',
239 'entity' => 'Country',
240 'bao' => 'CRM_Core_BAO_Country',
241 'localizable' => 0,
242 'add' => '1.1',
243 ],
244 'ndd_prefix' => [
245 'name' => 'ndd_prefix',
246 'type' => CRM_Utils_Type::T_STRING,
247 'title' => ts('Area Code'),
248 'description' => ts('Access prefix to call within a country to a different area'),
249 'maxlength' => 4,
250 'size' => CRM_Utils_Type::FOUR,
251 'where' => 'civicrm_country.ndd_prefix',
252 'table_name' => 'civicrm_country',
253 'entity' => 'Country',
254 'bao' => 'CRM_Core_BAO_Country',
255 'localizable' => 0,
256 'add' => '1.1',
257 ],
258 'region_id' => [
259 'name' => 'region_id',
260 'type' => CRM_Utils_Type::T_INT,
261 'title' => ts('World Region ID'),
262 'description' => ts('Foreign key to civicrm_worldregion.id.'),
263 'required' => TRUE,
264 'where' => 'civicrm_country.region_id',
265 'table_name' => 'civicrm_country',
266 'entity' => 'Country',
267 'bao' => 'CRM_Core_BAO_Country',
268 'localizable' => 0,
269 'localize_context' => 'country',
270 'FKClassName' => 'CRM_Core_DAO_Worldregion',
271 'html' => [
272 'label' => ts("World Region"),
273 ],
274 'pseudoconstant' => [
275 'table' => 'civicrm_worldregion',
276 'keyColumn' => 'id',
277 'labelColumn' => 'name',
278 ],
279 'add' => '1.8',
280 ],
281 'is_province_abbreviated' => [
282 'name' => 'is_province_abbreviated',
283 'type' => CRM_Utils_Type::T_BOOLEAN,
284 'title' => ts('Abbreviate Province?'),
285 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'),
286 'where' => 'civicrm_country.is_province_abbreviated',
287 'default' => '0',
288 'table_name' => 'civicrm_country',
289 'entity' => 'Country',
290 'bao' => 'CRM_Core_BAO_Country',
291 'localizable' => 0,
292 'add' => '3.1',
293 ],
294 'is_active' => [
295 'name' => 'is_active',
296 'type' => CRM_Utils_Type::T_BOOLEAN,
297 'title' => ts('Country Is Active'),
298 'description' => ts('Is this Country active?'),
299 'where' => 'civicrm_country.is_active',
300 'default' => '1',
301 'table_name' => 'civicrm_country',
302 'entity' => 'Country',
303 'bao' => 'CRM_Core_BAO_Country',
304 'localizable' => 0,
305 'add' => '5.35',
306 ],
307 ];
308 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
309 }
310 return Civi::$statics[__CLASS__]['fields'];
311 }
312
313 /**
314 * Return a mapping from field-name to the corresponding key (as used in fields()).
315 *
316 * @return array
317 * Array(string $name => string $uniqueName).
318 */
319 public static function &fieldKeys() {
320 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
321 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
322 }
323 return Civi::$statics[__CLASS__]['fieldKeys'];
324 }
325
326 /**
327 * Returns the names of this table
328 *
329 * @return string
330 */
331 public static function getTableName() {
332 return self::$_tableName;
333 }
334
335 /**
336 * Returns if this table needs to be logged
337 *
338 * @return bool
339 */
340 public function getLog() {
341 return self::$_log;
342 }
343
344 /**
345 * Returns the list of fields that can be imported
346 *
347 * @param bool $prefix
348 *
349 * @return array
350 */
351 public static function &import($prefix = FALSE) {
352 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'country', $prefix, []);
353 return $r;
354 }
355
356 /**
357 * Returns the list of fields that can be exported
358 *
359 * @param bool $prefix
360 *
361 * @return array
362 */
363 public static function &export($prefix = FALSE) {
364 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'country', $prefix, []);
365 return $r;
366 }
367
368 /**
369 * Returns the list of indices
370 *
371 * @param bool $localize
372 *
373 * @return array
374 */
375 public static function indices($localize = TRUE) {
376 $indices = [
377 'UI_name_iso_code' => [
378 'name' => 'UI_name_iso_code',
379 'field' => [
380 0 => 'name',
381 1 => 'iso_code',
382 ],
383 'localizable' => FALSE,
384 'unique' => TRUE,
385 'sig' => 'civicrm_country::1::name::iso_code',
386 ],
387 ];
388 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
389 }
390
391 }