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