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