Make phpType definitions in generated DAO objects more accurate.
[civicrm-core.git] / CRM / Contact / DAO / ContactType.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/Contact/ContactType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
2562d09a 9 * (GenCodeChecksum:f1913952f114c2ac041dfba5fef49d5d)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the ContactType entity.
f41f0342 14 */
e501603b 15class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '3.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_contact_type';
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 * Contact Type ID
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * Internal name of Contact Type (or Subtype).
42 *
43 * @var string
44 */
45 public $name;
c3fc2621 46
e501603b
TO
47 /**
48 * localized Name of Contact Type.
49 *
50 * @var string
51 */
52 public $label;
c3fc2621 53
e501603b
TO
54 /**
55 * localized Optional verbose description of the type.
56 *
57 * @var text
58 */
59 public $description;
c3fc2621 60
e501603b
TO
61 /**
62 * URL of image if any.
63 *
64 * @var string
65 */
66 public $image_URL;
c3fc2621 67
e501603b
TO
68 /**
69 * Optional FK to parent contact type.
70 *
e6ca0a57 71 * @var int
e501603b
TO
72 */
73 public $parent_id;
c3fc2621 74
e501603b
TO
75 /**
76 * Is this entry active?
77 *
e6ca0a57 78 * @var bool
e501603b
TO
79 */
80 public $is_active;
c3fc2621 81
e501603b
TO
82 /**
83 * Is this contact type a predefined system type
84 *
e6ca0a57 85 * @var bool
e501603b
TO
86 */
87 public $is_reserved;
c3fc2621 88
e501603b 89 /**
f41f0342 90 * Class constructor.
e501603b 91 */
c3fc2621 92 public function __construct() {
e501603b
TO
93 $this->__table = 'civicrm_contact_type';
94 parent::__construct();
95 }
c3fc2621 96
449c4e6b
CW
97 /**
98 * Returns localized title of this entity.
7b66c3b5
AH
99 *
100 * @param bool $plural
101 * Whether to return the plural version of the title.
449c4e6b 102 */
7b66c3b5
AH
103 public static function getEntityTitle($plural = FALSE) {
104 return $plural ? ts('Contact Types') : ts('Contact Type');
449c4e6b
CW
105 }
106
e501603b 107 /**
f41f0342 108 * Returns foreign keys and entity references.
e501603b
TO
109 *
110 * @return array
111 * [CRM_Core_Reference_Interface]
112 */
c3fc2621 113 public static function getReferenceColumns() {
346aaaba 114 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 115 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 116 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_contact_type', 'id');
346aaaba 117 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 118 }
346aaaba 119 return Civi::$statics[__CLASS__]['links'];
e501603b 120 }
c3fc2621 121
e501603b
TO
122 /**
123 * Returns all the column names of this table
124 *
125 * @return array
126 */
c3fc2621 127 public static function &fields() {
346aaaba 128 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
129 Civi::$statics[__CLASS__]['fields'] = [
130 'id' => [
e501603b
TO
131 'name' => 'id',
132 'type' => CRM_Utils_Type::T_INT,
c3fc2621 133 'title' => ts('Contact Type ID'),
215b423e 134 'description' => ts('Contact Type ID'),
c3fc2621 135 'required' => TRUE,
a36434b9 136 'where' => 'civicrm_contact_type.id',
522a26c9 137 'table_name' => 'civicrm_contact_type',
138 'entity' => 'ContactType',
139 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 140 'localizable' => 0,
2cbbebe8
A
141 'html' => [
142 'type' => 'Number',
143 ],
1fe423d6 144 'readonly' => TRUE,
a9d0587b 145 'add' => '1.1',
c3fc2621
CW
146 ],
147 'name' => [
e501603b
TO
148 'name' => 'name',
149 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 150 'title' => ts('Name'),
215b423e 151 'description' => ts('Internal name of Contact Type (or Subtype).'),
351e8d47 152 'required' => TRUE,
e501603b
TO
153 'maxlength' => 64,
154 'size' => CRM_Utils_Type::BIG,
a36434b9 155 'where' => 'civicrm_contact_type.name',
522a26c9 156 'table_name' => 'civicrm_contact_type',
157 'entity' => 'ContactType',
158 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 159 'localizable' => 0,
c23563e3
SL
160 'html' => [
161 'label' => ts("Name"),
162 ],
a9d0587b 163 'add' => '3.1',
c3fc2621
CW
164 ],
165 'label' => [
e501603b
TO
166 'name' => 'label',
167 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 168 'title' => ts('Contact Type Label'),
215b423e 169 'description' => ts('localized Name of Contact Type.'),
e501603b
TO
170 'maxlength' => 64,
171 'size' => CRM_Utils_Type::BIG,
a36434b9 172 'where' => 'civicrm_contact_type.label',
522a26c9 173 'table_name' => 'civicrm_contact_type',
174 'entity' => 'ContactType',
175 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 176 'localizable' => 1,
a9d0587b 177 'add' => '3.1',
c3fc2621
CW
178 ],
179 'description' => [
e501603b
TO
180 'name' => 'description',
181 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 182 'title' => ts('Contact Type Description'),
215b423e 183 'description' => ts('localized Optional verbose description of the type.'),
e501603b
TO
184 'rows' => 2,
185 'cols' => 60,
a36434b9 186 'where' => 'civicrm_contact_type.description',
522a26c9 187 'table_name' => 'civicrm_contact_type',
188 'entity' => 'ContactType',
189 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 190 'localizable' => 1,
c3fc2621 191 'html' => [
e501603b 192 'type' => 'TextArea',
c3fc2621 193 ],
a9d0587b 194 'add' => '3.1',
c3fc2621
CW
195 ],
196 'image_URL' => [
e501603b
TO
197 'name' => 'image_URL',
198 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 199 'title' => ts('Contact Type Image URL'),
215b423e 200 'description' => ts('URL of image if any.'),
e501603b
TO
201 'maxlength' => 255,
202 'size' => CRM_Utils_Type::HUGE,
a36434b9 203 'where' => 'civicrm_contact_type.image_URL',
522a26c9 204 'table_name' => 'civicrm_contact_type',
205 'entity' => 'ContactType',
206 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 207 'localizable' => 0,
a9d0587b 208 'add' => '3.1',
c3fc2621
CW
209 ],
210 'parent_id' => [
e501603b
TO
211 'name' => 'parent_id',
212 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 213 'title' => ts('Parent ID'),
215b423e 214 'description' => ts('Optional FK to parent contact type.'),
a36434b9 215 'where' => 'civicrm_contact_type.parent_id',
522a26c9 216 'table_name' => 'civicrm_contact_type',
217 'entity' => 'ContactType',
218 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 219 'localizable' => 0,
e501603b 220 'FKClassName' => 'CRM_Contact_DAO_ContactType',
2cbbebe8
A
221 'html' => [
222 'label' => ts("Parent"),
223 ],
c3fc2621 224 'pseudoconstant' => [
e501603b
TO
225 'table' => 'civicrm_contact_type',
226 'keyColumn' => 'id',
227 'labelColumn' => 'label',
228 'condition' => 'parent_id IS NULL',
e6ca0a57 229 ],
a9d0587b 230 'add' => '3.1',
c3fc2621
CW
231 ],
232 'is_active' => [
e501603b
TO
233 'name' => 'is_active',
234 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 235 'title' => ts('Contact Type Is Active?'),
215b423e 236 'description' => ts('Is this entry active?'),
a36434b9 237 'where' => 'civicrm_contact_type.is_active',
351e8d47 238 'default' => '1',
522a26c9 239 'table_name' => 'civicrm_contact_type',
240 'entity' => 'ContactType',
241 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 242 'localizable' => 0,
a9d0587b 243 'add' => '3.1',
c3fc2621
CW
244 ],
245 'is_reserved' => [
e501603b
TO
246 'name' => 'is_reserved',
247 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 248 'title' => ts('Contact Type is Reserved?'),
215b423e 249 'description' => ts('Is this contact type a predefined system type'),
a36434b9 250 'where' => 'civicrm_contact_type.is_reserved',
351e8d47 251 'default' => '0',
522a26c9 252 'table_name' => 'civicrm_contact_type',
253 'entity' => 'ContactType',
254 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 255 'localizable' => 0,
a9d0587b 256 'add' => '3.1',
c3fc2621
CW
257 ],
258 ];
346aaaba 259 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 260 }
346aaaba 261 return Civi::$statics[__CLASS__]['fields'];
e501603b 262 }
c3fc2621 263
e501603b 264 /**
bd8e0b14 265 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
266 *
267 * @return array
bd8e0b14 268 * Array(string $name => string $uniqueName).
e501603b 269 */
c3fc2621 270 public static function &fieldKeys() {
bd8e0b14
TO
271 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
272 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 273 }
bd8e0b14 274 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 275 }
c3fc2621 276
e501603b
TO
277 /**
278 * Returns the names of this table
279 *
280 * @return string
281 */
c3fc2621 282 public static function getTableName() {
e501603b
TO
283 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
284 }
c3fc2621 285
e501603b
TO
286 /**
287 * Returns if this table needs to be logged
288 *
c3fc2621 289 * @return bool
e501603b 290 */
c3fc2621 291 public function getLog() {
e501603b
TO
292 return self::$_log;
293 }
c3fc2621 294
e501603b
TO
295 /**
296 * Returns the list of fields that can be imported
297 *
298 * @param bool $prefix
299 *
300 * @return array
301 */
c3fc2621
CW
302 public static function &import($prefix = FALSE) {
303 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contact_type', $prefix, []);
60808919 304 return $r;
e501603b 305 }
c3fc2621 306
e501603b
TO
307 /**
308 * Returns the list of fields that can be exported
309 *
310 * @param bool $prefix
311 *
312 * @return array
313 */
c3fc2621
CW
314 public static function &export($prefix = FALSE) {
315 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contact_type', $prefix, []);
60808919 316 return $r;
e501603b 317 }
c3fc2621 318
e7a6b91a
AS
319 /**
320 * Returns the list of indices
c3fc2621
CW
321 *
322 * @param bool $localize
323 *
324 * @return array
e7a6b91a
AS
325 */
326 public static function indices($localize = TRUE) {
c3fc2621
CW
327 $indices = [
328 'contact_type' => [
e7a6b91a 329 'name' => 'contact_type',
c3fc2621 330 'field' => [
e7a6b91a 331 0 => 'name',
c3fc2621
CW
332 ],
333 'localizable' => FALSE,
334 'unique' => TRUE,
e7a6b91a 335 'sig' => 'civicrm_contact_type::1::name',
c3fc2621
CW
336 ],
337 ];
e7a6b91a
AS
338 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
339 }
c3fc2621 340
e501603b 341}