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