Merge pull request #19205 from eileenmcnaughton/mem_forms
[civicrm-core.git] / CRM / Core / DAO / StateProvince.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/StateProvince.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
d31fb4e3 9 * (GenCodeChecksum:abd329da6e7801c901c3c97c1b09ef59)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the StateProvince entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_StateProvince extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
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_state_province';
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 = FALSE;
c3fc2621 32
e501603b
TO
33 /**
34 * State/Province ID
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * Name of State/Province
42 *
43 * @var string
44 */
45 public $name;
c3fc2621 46
e501603b
TO
47 /**
48 * 2-4 Character Abbreviation of State/Province
49 *
50 * @var string
51 */
52 public $abbreviation;
c3fc2621 53
e501603b
TO
54 /**
55 * ID of Country that State/Province belong
56 *
e6ca0a57 57 * @var int
e501603b
TO
58 */
59 public $country_id;
c3fc2621 60
e501603b 61 /**
f41f0342 62 * Class constructor.
e501603b 63 */
c3fc2621 64 public function __construct() {
e501603b
TO
65 $this->__table = 'civicrm_state_province';
66 parent::__construct();
67 }
c3fc2621 68
449c4e6b
CW
69 /**
70 * Returns localized title of this entity.
7b66c3b5
AH
71 *
72 * @param bool $plural
73 * Whether to return the plural version of the title.
449c4e6b 74 */
7b66c3b5 75 public static function getEntityTitle($plural = FALSE) {
5ad66c4f 76 return $plural ? ts('States/Provinces') : ts('State/Province');
449c4e6b
CW
77 }
78
e501603b 79 /**
f41f0342 80 * Returns foreign keys and entity references.
e501603b
TO
81 *
82 * @return array
83 * [CRM_Core_Reference_Interface]
84 */
c3fc2621 85 public static function getReferenceColumns() {
346aaaba 86 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 87 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 88 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'country_id', 'civicrm_country', 'id');
346aaaba 89 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 90 }
346aaaba 91 return Civi::$statics[__CLASS__]['links'];
e501603b 92 }
c3fc2621 93
e501603b
TO
94 /**
95 * Returns all the column names of this table
96 *
97 * @return array
98 */
c3fc2621 99 public static function &fields() {
346aaaba 100 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
101 Civi::$statics[__CLASS__]['fields'] = [
102 'id' => [
e501603b
TO
103 'name' => 'id',
104 'type' => CRM_Utils_Type::T_INT,
c3fc2621 105 'title' => ts('State ID'),
215b423e 106 'description' => ts('State/Province ID'),
c3fc2621 107 'required' => TRUE,
a36434b9 108 'where' => 'civicrm_state_province.id',
522a26c9 109 'table_name' => 'civicrm_state_province',
110 'entity' => 'StateProvince',
111 'bao' => 'CRM_Core_DAO_StateProvince',
6a7e5e5d 112 'localizable' => 0,
a9d0587b 113 'add' => '1.1',
c3fc2621
CW
114 ],
115 'name' => [
e501603b
TO
116 'name' => 'name',
117 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 118 'title' => ts('State'),
215b423e 119 'description' => ts('Name of State/Province'),
e501603b
TO
120 'maxlength' => 64,
121 'size' => CRM_Utils_Type::BIG,
c3fc2621 122 'import' => TRUE,
e501603b
TO
123 'where' => 'civicrm_state_province.name',
124 'headerPattern' => '/state|prov(ince)?/i',
125 'dataPattern' => '/[A-Z]{2}/',
c3fc2621 126 'export' => TRUE,
522a26c9 127 'table_name' => 'civicrm_state_province',
128 'entity' => 'StateProvince',
129 'bao' => 'CRM_Core_DAO_StateProvince',
6a7e5e5d 130 'localizable' => 0,
a9d0587b 131 'add' => '1.1',
c3fc2621
CW
132 ],
133 'abbreviation' => [
e501603b
TO
134 'name' => 'abbreviation',
135 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 136 'title' => ts('State Abbreviation'),
215b423e 137 'description' => ts('2-4 Character Abbreviation of State/Province'),
e501603b
TO
138 'maxlength' => 4,
139 'size' => CRM_Utils_Type::FOUR,
a36434b9 140 'where' => 'civicrm_state_province.abbreviation',
522a26c9 141 'table_name' => 'civicrm_state_province',
142 'entity' => 'StateProvince',
143 'bao' => 'CRM_Core_DAO_StateProvince',
6a7e5e5d 144 'localizable' => 0,
a9d0587b 145 'add' => '1.1',
c3fc2621
CW
146 ],
147 'country_id' => [
e501603b
TO
148 'name' => 'country_id',
149 'type' => CRM_Utils_Type::T_INT,
c3fc2621 150 'title' => ts('Country'),
215b423e 151 'description' => ts('ID of Country that State/Province belong'),
c3fc2621 152 'required' => TRUE,
a36434b9 153 'where' => 'civicrm_state_province.country_id',
522a26c9 154 'table_name' => 'civicrm_state_province',
155 'entity' => 'StateProvince',
156 'bao' => 'CRM_Core_DAO_StateProvince',
6a7e5e5d 157 'localizable' => 0,
e501603b 158 'FKClassName' => 'CRM_Core_DAO_Country',
a9d0587b 159 'add' => '1.1',
c3fc2621
CW
160 ],
161 ];
346aaaba 162 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 163 }
346aaaba 164 return Civi::$statics[__CLASS__]['fields'];
e501603b 165 }
c3fc2621 166
e501603b 167 /**
bd8e0b14 168 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
169 *
170 * @return array
bd8e0b14 171 * Array(string $name => string $uniqueName).
e501603b 172 */
c3fc2621 173 public static function &fieldKeys() {
bd8e0b14
TO
174 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
175 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 176 }
bd8e0b14 177 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 178 }
c3fc2621 179
e501603b
TO
180 /**
181 * Returns the names of this table
182 *
183 * @return string
184 */
c3fc2621 185 public static function getTableName() {
e501603b
TO
186 return self::$_tableName;
187 }
c3fc2621 188
e501603b
TO
189 /**
190 * Returns if this table needs to be logged
191 *
c3fc2621 192 * @return bool
e501603b 193 */
c3fc2621 194 public function getLog() {
e501603b
TO
195 return self::$_log;
196 }
c3fc2621 197
e501603b
TO
198 /**
199 * Returns the list of fields that can be imported
200 *
201 * @param bool $prefix
202 *
203 * @return array
204 */
c3fc2621
CW
205 public static function &import($prefix = FALSE) {
206 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'state_province', $prefix, []);
60808919 207 return $r;
e501603b 208 }
c3fc2621 209
e501603b
TO
210 /**
211 * Returns the list of fields that can be exported
212 *
213 * @param bool $prefix
214 *
215 * @return array
216 */
c3fc2621
CW
217 public static function &export($prefix = FALSE) {
218 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'state_province', $prefix, []);
60808919 219 return $r;
e501603b 220 }
c3fc2621 221
e7a6b91a
AS
222 /**
223 * Returns the list of indices
c3fc2621
CW
224 *
225 * @param bool $localize
226 *
227 * @return array
e7a6b91a
AS
228 */
229 public static function indices($localize = TRUE) {
c3fc2621
CW
230 $indices = [
231 'UI_name_country_id' => [
e7a6b91a 232 'name' => 'UI_name_country_id',
c3fc2621 233 'field' => [
e7a6b91a
AS
234 0 => 'name',
235 1 => 'country_id',
c3fc2621
CW
236 ],
237 'localizable' => FALSE,
238 'unique' => TRUE,
e7a6b91a 239 'sig' => 'civicrm_state_province::1::name::country_id',
c3fc2621
CW
240 ],
241 ];
e7a6b91a
AS
242 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
243 }
c3fc2621 244
e501603b 245}