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