Merge pull request #19525 from eileenmcnaughton/member_soft
[civicrm-core.git] / CRM / Core / DAO / StateProvince.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/StateProvince.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:1fa57e7255ecf375deb13ccb9d86fefe)
10 */
11
12 /**
13 * Database access object for the StateProvince entity.
14 */
15 class CRM_Core_DAO_StateProvince 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_state_province';
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 * State/Province ID
42 *
43 * @var int
44 */
45 public $id;
46
47 /**
48 * Name of State/Province
49 *
50 * @var string
51 */
52 public $name;
53
54 /**
55 * 2-4 Character Abbreviation of State/Province
56 *
57 * @var string
58 */
59 public $abbreviation;
60
61 /**
62 * ID of Country that State/Province belong
63 *
64 * @var int
65 */
66 public $country_id;
67
68 /**
69 * Is this StateProvince active?
70 *
71 * @var bool
72 */
73 public $is_active;
74
75 /**
76 * Class constructor.
77 */
78 public function __construct() {
79 $this->__table = 'civicrm_state_province';
80 parent::__construct();
81 }
82
83 /**
84 * Returns localized title of this entity.
85 *
86 * @param bool $plural
87 * Whether to return the plural version of the title.
88 */
89 public static function getEntityTitle($plural = FALSE) {
90 return $plural ? ts('States/Provinces') : ts('State/Province');
91 }
92
93 /**
94 * Returns foreign keys and entity references.
95 *
96 * @return array
97 * [CRM_Core_Reference_Interface]
98 */
99 public static function getReferenceColumns() {
100 if (!isset(Civi::$statics[__CLASS__]['links'])) {
101 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
102 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'country_id', 'civicrm_country', 'id');
103 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
104 }
105 return Civi::$statics[__CLASS__]['links'];
106 }
107
108 /**
109 * Returns all the column names of this table
110 *
111 * @return array
112 */
113 public static function &fields() {
114 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
115 Civi::$statics[__CLASS__]['fields'] = [
116 'id' => [
117 'name' => 'id',
118 'type' => CRM_Utils_Type::T_INT,
119 'title' => ts('State ID'),
120 'description' => ts('State/Province ID'),
121 'required' => TRUE,
122 'where' => 'civicrm_state_province.id',
123 'table_name' => 'civicrm_state_province',
124 'entity' => 'StateProvince',
125 'bao' => 'CRM_Core_DAO_StateProvince',
126 'localizable' => 0,
127 'html' => [
128 'type' => 'Number',
129 ],
130 'add' => '1.1',
131 ],
132 'name' => [
133 'name' => 'name',
134 'type' => CRM_Utils_Type::T_STRING,
135 'title' => ts('State'),
136 'description' => ts('Name of State/Province'),
137 'maxlength' => 64,
138 'size' => CRM_Utils_Type::BIG,
139 'import' => TRUE,
140 'where' => 'civicrm_state_province.name',
141 'headerPattern' => '/state|prov(ince)?/i',
142 'dataPattern' => '/[A-Z]{2}/',
143 'export' => TRUE,
144 'table_name' => 'civicrm_state_province',
145 'entity' => 'StateProvince',
146 'bao' => 'CRM_Core_DAO_StateProvince',
147 'localizable' => 0,
148 'add' => '1.1',
149 ],
150 'abbreviation' => [
151 'name' => 'abbreviation',
152 'type' => CRM_Utils_Type::T_STRING,
153 'title' => ts('State Abbreviation'),
154 'description' => ts('2-4 Character Abbreviation of State/Province'),
155 'maxlength' => 4,
156 'size' => CRM_Utils_Type::FOUR,
157 'where' => 'civicrm_state_province.abbreviation',
158 'table_name' => 'civicrm_state_province',
159 'entity' => 'StateProvince',
160 'bao' => 'CRM_Core_DAO_StateProvince',
161 'localizable' => 0,
162 'add' => '1.1',
163 ],
164 'country_id' => [
165 'name' => 'country_id',
166 'type' => CRM_Utils_Type::T_INT,
167 'title' => ts('Country ID'),
168 'description' => ts('ID of Country that State/Province belong'),
169 'required' => TRUE,
170 'where' => 'civicrm_state_province.country_id',
171 'table_name' => 'civicrm_state_province',
172 'entity' => 'StateProvince',
173 'bao' => 'CRM_Core_DAO_StateProvince',
174 'localizable' => 0,
175 'FKClassName' => 'CRM_Core_DAO_Country',
176 'html' => [
177 'label' => ts("Country"),
178 ],
179 'add' => '1.1',
180 ],
181 'is_active' => [
182 'name' => 'is_active',
183 'type' => CRM_Utils_Type::T_BOOLEAN,
184 'title' => ts('StateProvince Is Active'),
185 'description' => ts('Is this StateProvince active?'),
186 'where' => 'civicrm_state_province.is_active',
187 'default' => '1',
188 'table_name' => 'civicrm_state_province',
189 'entity' => 'StateProvince',
190 'bao' => 'CRM_Core_DAO_StateProvince',
191 'localizable' => 0,
192 'add' => '5.35',
193 ],
194 ];
195 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
196 }
197 return Civi::$statics[__CLASS__]['fields'];
198 }
199
200 /**
201 * Return a mapping from field-name to the corresponding key (as used in fields()).
202 *
203 * @return array
204 * Array(string $name => string $uniqueName).
205 */
206 public static function &fieldKeys() {
207 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
208 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
209 }
210 return Civi::$statics[__CLASS__]['fieldKeys'];
211 }
212
213 /**
214 * Returns the names of this table
215 *
216 * @return string
217 */
218 public static function getTableName() {
219 return self::$_tableName;
220 }
221
222 /**
223 * Returns if this table needs to be logged
224 *
225 * @return bool
226 */
227 public function getLog() {
228 return self::$_log;
229 }
230
231 /**
232 * Returns the list of fields that can be imported
233 *
234 * @param bool $prefix
235 *
236 * @return array
237 */
238 public static function &import($prefix = FALSE) {
239 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'state_province', $prefix, []);
240 return $r;
241 }
242
243 /**
244 * Returns the list of fields that can be exported
245 *
246 * @param bool $prefix
247 *
248 * @return array
249 */
250 public static function &export($prefix = FALSE) {
251 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'state_province', $prefix, []);
252 return $r;
253 }
254
255 /**
256 * Returns the list of indices
257 *
258 * @param bool $localize
259 *
260 * @return array
261 */
262 public static function indices($localize = TRUE) {
263 $indices = [
264 'UI_name_country_id' => [
265 'name' => 'UI_name_country_id',
266 'field' => [
267 0 => 'name',
268 1 => 'country_id',
269 ],
270 'localizable' => FALSE,
271 'unique' => TRUE,
272 'sig' => 'civicrm_state_province::1::name::country_id',
273 ],
274 ];
275 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
276 }
277
278 }