Merge pull request #19507 from eileenmcnaughton/trans
[civicrm-core.git] / CRM / Core / DAO / County.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/County.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:483d29dbf44ee6e0805f062f90a1d4e9)
10 */
11
12 /**
13 * Database access object for the County entity.
14 */
15 class CRM_Core_DAO_County 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_county';
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 * County ID
42 *
43 * @var int
44 */
45 public $id;
46
47 /**
48 * Name of County
49 *
50 * @var string
51 */
52 public $name;
53
54 /**
55 * 2-4 Character Abbreviation of County
56 *
57 * @var string
58 */
59 public $abbreviation;
60
61 /**
62 * ID of State/Province that County belongs
63 *
64 * @var int
65 */
66 public $state_province_id;
67
68 /**
69 * Is this County active?
70 *
71 * @var bool
72 */
73 public $is_active;
74
75 /**
76 * Class constructor.
77 */
78 public function __construct() {
79 $this->__table = 'civicrm_county';
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('Counties') : ts('County');
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(), 'state_province_id', 'civicrm_state_province', '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('County ID'),
120 'description' => ts('County ID'),
121 'required' => TRUE,
122 'where' => 'civicrm_county.id',
123 'table_name' => 'civicrm_county',
124 'entity' => 'County',
125 'bao' => 'CRM_Core_DAO_County',
126 'localizable' => 0,
127 'add' => '1.1',
128 ],
129 'name' => [
130 'name' => 'name',
131 'type' => CRM_Utils_Type::T_STRING,
132 'title' => ts('County'),
133 'description' => ts('Name of County'),
134 'maxlength' => 64,
135 'size' => CRM_Utils_Type::BIG,
136 'import' => TRUE,
137 'where' => 'civicrm_county.name',
138 'headerPattern' => '/county/i',
139 'dataPattern' => '/[A-Z]{2}/',
140 'export' => TRUE,
141 'table_name' => 'civicrm_county',
142 'entity' => 'County',
143 'bao' => 'CRM_Core_DAO_County',
144 'localizable' => 0,
145 'add' => '1.1',
146 ],
147 'abbreviation' => [
148 'name' => 'abbreviation',
149 'type' => CRM_Utils_Type::T_STRING,
150 'title' => ts('County Abbreviation'),
151 'description' => ts('2-4 Character Abbreviation of County'),
152 'maxlength' => 4,
153 'size' => CRM_Utils_Type::FOUR,
154 'where' => 'civicrm_county.abbreviation',
155 'table_name' => 'civicrm_county',
156 'entity' => 'County',
157 'bao' => 'CRM_Core_DAO_County',
158 'localizable' => 0,
159 'add' => '1.1',
160 ],
161 'state_province_id' => [
162 'name' => 'state_province_id',
163 'type' => CRM_Utils_Type::T_INT,
164 'title' => ts('State'),
165 'description' => ts('ID of State/Province that County belongs'),
166 'required' => TRUE,
167 'where' => 'civicrm_county.state_province_id',
168 'table_name' => 'civicrm_county',
169 'entity' => 'County',
170 'bao' => 'CRM_Core_DAO_County',
171 'localizable' => 0,
172 'FKClassName' => 'CRM_Core_DAO_StateProvince',
173 'pseudoconstant' => [
174 'table' => 'civicrm_state_province',
175 'keyColumn' => 'id',
176 'labelColumn' => 'name',
177 ],
178 'add' => '1.1',
179 ],
180 'is_active' => [
181 'name' => 'is_active',
182 'type' => CRM_Utils_Type::T_BOOLEAN,
183 'title' => ts('County Is Active'),
184 'description' => ts('Is this County active?'),
185 'where' => 'civicrm_county.is_active',
186 'default' => '1',
187 'table_name' => 'civicrm_county',
188 'entity' => 'County',
189 'bao' => 'CRM_Core_DAO_County',
190 'localizable' => 0,
191 'add' => '5.35',
192 ],
193 ];
194 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
195 }
196 return Civi::$statics[__CLASS__]['fields'];
197 }
198
199 /**
200 * Return a mapping from field-name to the corresponding key (as used in fields()).
201 *
202 * @return array
203 * Array(string $name => string $uniqueName).
204 */
205 public static function &fieldKeys() {
206 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
207 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
208 }
209 return Civi::$statics[__CLASS__]['fieldKeys'];
210 }
211
212 /**
213 * Returns the names of this table
214 *
215 * @return string
216 */
217 public static function getTableName() {
218 return self::$_tableName;
219 }
220
221 /**
222 * Returns if this table needs to be logged
223 *
224 * @return bool
225 */
226 public function getLog() {
227 return self::$_log;
228 }
229
230 /**
231 * Returns the list of fields that can be imported
232 *
233 * @param bool $prefix
234 *
235 * @return array
236 */
237 public static function &import($prefix = FALSE) {
238 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'county', $prefix, []);
239 return $r;
240 }
241
242 /**
243 * Returns the list of fields that can be exported
244 *
245 * @param bool $prefix
246 *
247 * @return array
248 */
249 public static function &export($prefix = FALSE) {
250 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'county', $prefix, []);
251 return $r;
252 }
253
254 /**
255 * Returns the list of indices
256 *
257 * @param bool $localize
258 *
259 * @return array
260 */
261 public static function indices($localize = TRUE) {
262 $indices = [
263 'UI_name_state_id' => [
264 'name' => 'UI_name_state_id',
265 'field' => [
266 0 => 'name',
267 1 => 'state_province_id',
268 ],
269 'localizable' => FALSE,
270 'unique' => TRUE,
271 'sig' => 'civicrm_county::1::name::state_province_id',
272 ],
273 ];
274 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
275 }
276
277 }