[REF] Extract determination of subscription status information
[civicrm-core.git] / CRM / Core / DAO / County.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/County.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
d31fb4e3 9 * (GenCodeChecksum:9e49f92ab040fc02002d5ec5507cf49a)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the County entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_County 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_county';
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 * County ID
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * Name of County
42 *
43 * @var string
44 */
45 public $name;
c3fc2621 46
e501603b
TO
47 /**
48 * 2-4 Character Abbreviation of County
49 *
50 * @var string
51 */
52 public $abbreviation;
c3fc2621 53
e501603b
TO
54 /**
55 * ID of State/Province that County belongs
56 *
e6ca0a57 57 * @var int
e501603b
TO
58 */
59 public $state_province_id;
c3fc2621 60
e501603b 61 /**
f41f0342 62 * Class constructor.
e501603b 63 */
c3fc2621 64 public function __construct() {
e501603b
TO
65 $this->__table = 'civicrm_county';
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
AH
75 public static function getEntityTitle($plural = FALSE) {
76 return $plural ? ts('Counties') : ts('County');
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(), 'state_province_id', 'civicrm_state_province', '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('County ID'),
215b423e 106 'description' => ts('County ID'),
c3fc2621 107 'required' => TRUE,
a36434b9 108 'where' => 'civicrm_county.id',
522a26c9 109 'table_name' => 'civicrm_county',
110 'entity' => 'County',
111 'bao' => 'CRM_Core_DAO_County',
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('County'),
215b423e 119 'description' => ts('Name of County'),
e501603b
TO
120 'maxlength' => 64,
121 'size' => CRM_Utils_Type::BIG,
c3fc2621 122 'import' => TRUE,
e501603b
TO
123 'where' => 'civicrm_county.name',
124 'headerPattern' => '/county/i',
125 'dataPattern' => '/[A-Z]{2}/',
c3fc2621 126 'export' => TRUE,
522a26c9 127 'table_name' => 'civicrm_county',
128 'entity' => 'County',
129 'bao' => 'CRM_Core_DAO_County',
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('County Abbreviation'),
215b423e 137 'description' => ts('2-4 Character Abbreviation of County'),
e501603b
TO
138 'maxlength' => 4,
139 'size' => CRM_Utils_Type::FOUR,
a36434b9 140 'where' => 'civicrm_county.abbreviation',
522a26c9 141 'table_name' => 'civicrm_county',
142 'entity' => 'County',
143 'bao' => 'CRM_Core_DAO_County',
6a7e5e5d 144 'localizable' => 0,
a9d0587b 145 'add' => '1.1',
c3fc2621
CW
146 ],
147 'state_province_id' => [
e501603b
TO
148 'name' => 'state_province_id',
149 'type' => CRM_Utils_Type::T_INT,
c3fc2621 150 'title' => ts('State'),
215b423e 151 'description' => ts('ID of State/Province that County belongs'),
c3fc2621 152 'required' => TRUE,
a36434b9 153 'where' => 'civicrm_county.state_province_id',
522a26c9 154 'table_name' => 'civicrm_county',
155 'entity' => 'County',
156 'bao' => 'CRM_Core_DAO_County',
6a7e5e5d 157 'localizable' => 0,
e501603b 158 'FKClassName' => 'CRM_Core_DAO_StateProvince',
96012881
PN
159 'pseudoconstant' => [
160 'table' => 'civicrm_state_province',
161 'keyColumn' => 'id',
162 'labelColumn' => 'name',
163 ],
a9d0587b 164 'add' => '1.1',
c3fc2621
CW
165 ],
166 ];
346aaaba 167 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 168 }
346aaaba 169 return Civi::$statics[__CLASS__]['fields'];
e501603b 170 }
c3fc2621 171
e501603b 172 /**
bd8e0b14 173 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
174 *
175 * @return array
bd8e0b14 176 * Array(string $name => string $uniqueName).
e501603b 177 */
c3fc2621 178 public static function &fieldKeys() {
bd8e0b14
TO
179 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
180 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 181 }
bd8e0b14 182 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 183 }
c3fc2621 184
e501603b
TO
185 /**
186 * Returns the names of this table
187 *
188 * @return string
189 */
c3fc2621 190 public static function getTableName() {
e501603b
TO
191 return self::$_tableName;
192 }
c3fc2621 193
e501603b
TO
194 /**
195 * Returns if this table needs to be logged
196 *
c3fc2621 197 * @return bool
e501603b 198 */
c3fc2621 199 public function getLog() {
e501603b
TO
200 return self::$_log;
201 }
c3fc2621 202
e501603b
TO
203 /**
204 * Returns the list of fields that can be imported
205 *
206 * @param bool $prefix
207 *
208 * @return array
209 */
c3fc2621
CW
210 public static function &import($prefix = FALSE) {
211 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'county', $prefix, []);
60808919 212 return $r;
e501603b 213 }
c3fc2621 214
e501603b
TO
215 /**
216 * Returns the list of fields that can be exported
217 *
218 * @param bool $prefix
219 *
220 * @return array
221 */
c3fc2621
CW
222 public static function &export($prefix = FALSE) {
223 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'county', $prefix, []);
60808919 224 return $r;
e501603b 225 }
c3fc2621 226
e7a6b91a
AS
227 /**
228 * Returns the list of indices
c3fc2621
CW
229 *
230 * @param bool $localize
231 *
232 * @return array
e7a6b91a
AS
233 */
234 public static function indices($localize = TRUE) {
c3fc2621
CW
235 $indices = [
236 'UI_name_state_id' => [
e7a6b91a 237 'name' => 'UI_name_state_id',
c3fc2621 238 'field' => [
e7a6b91a
AS
239 0 => 'name',
240 1 => 'state_province_id',
c3fc2621
CW
241 ],
242 'localizable' => FALSE,
243 'unique' => TRUE,
e7a6b91a 244 'sig' => 'civicrm_county::1::name::state_province_id',
c3fc2621
CW
245 ],
246 ];
e7a6b91a
AS
247 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
248 }
c3fc2621 249
e501603b 250}