Merge pull request #15314 from jitendrapurohit/dev-1255
[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:3ad338181596a9b5e3a9f6549fd381c9)
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 foreign keys and entity references.
97 *
98 * @return array
99 * [CRM_Core_Reference_Interface]
100 */
101 public static function getReferenceColumns() {
102 if (!isset(Civi::$statics[__CLASS__]['links'])) {
103 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
104 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_contact_type', 'id');
105 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
106 }
107 return Civi::$statics[__CLASS__]['links'];
108 }
109
110 /**
111 * Returns all the column names of this table
112 *
113 * @return array
114 */
115 public static function &fields() {
116 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
117 Civi::$statics[__CLASS__]['fields'] = [
118 'id' => [
119 'name' => 'id',
120 'type' => CRM_Utils_Type::T_INT,
121 'title' => ts('Contact Type ID'),
122 'description' => ts('Contact Type ID'),
123 'required' => TRUE,
124 'where' => 'civicrm_contact_type.id',
125 'table_name' => 'civicrm_contact_type',
126 'entity' => 'ContactType',
127 'bao' => 'CRM_Contact_BAO_ContactType',
128 'localizable' => 0,
129 ],
130 'name' => [
131 'name' => 'name',
132 'type' => CRM_Utils_Type::T_STRING,
133 'title' => ts('Name'),
134 'description' => ts('Internal name of Contact Type (or Subtype).'),
135 'maxlength' => 64,
136 'size' => CRM_Utils_Type::BIG,
137 'where' => 'civicrm_contact_type.name',
138 'table_name' => 'civicrm_contact_type',
139 'entity' => 'ContactType',
140 'bao' => 'CRM_Contact_BAO_ContactType',
141 'localizable' => 0,
142 ],
143 'label' => [
144 'name' => 'label',
145 'type' => CRM_Utils_Type::T_STRING,
146 'title' => ts('Contact Type Label'),
147 'description' => ts('localized Name of Contact Type.'),
148 'maxlength' => 64,
149 'size' => CRM_Utils_Type::BIG,
150 'where' => 'civicrm_contact_type.label',
151 'table_name' => 'civicrm_contact_type',
152 'entity' => 'ContactType',
153 'bao' => 'CRM_Contact_BAO_ContactType',
154 'localizable' => 1,
155 ],
156 'description' => [
157 'name' => 'description',
158 'type' => CRM_Utils_Type::T_TEXT,
159 'title' => ts('Contact Type Description'),
160 'description' => ts('localized Optional verbose description of the type.'),
161 'rows' => 2,
162 'cols' => 60,
163 'where' => 'civicrm_contact_type.description',
164 'table_name' => 'civicrm_contact_type',
165 'entity' => 'ContactType',
166 'bao' => 'CRM_Contact_BAO_ContactType',
167 'localizable' => 1,
168 'html' => [
169 'type' => 'TextArea',
170 ],
171 ],
172 'image_URL' => [
173 'name' => 'image_URL',
174 'type' => CRM_Utils_Type::T_STRING,
175 'title' => ts('Contact Type Image URL'),
176 'description' => ts('URL of image if any.'),
177 'maxlength' => 255,
178 'size' => CRM_Utils_Type::HUGE,
179 'where' => 'civicrm_contact_type.image_URL',
180 'table_name' => 'civicrm_contact_type',
181 'entity' => 'ContactType',
182 'bao' => 'CRM_Contact_BAO_ContactType',
183 'localizable' => 0,
184 ],
185 'parent_id' => [
186 'name' => 'parent_id',
187 'type' => CRM_Utils_Type::T_INT,
188 'title' => ts('Contact Type Parent'),
189 'description' => ts('Optional FK to parent contact type.'),
190 'where' => 'civicrm_contact_type.parent_id',
191 'table_name' => 'civicrm_contact_type',
192 'entity' => 'ContactType',
193 'bao' => 'CRM_Contact_BAO_ContactType',
194 'localizable' => 0,
195 'FKClassName' => 'CRM_Contact_DAO_ContactType',
196 'pseudoconstant' => [
197 'table' => 'civicrm_contact_type',
198 'keyColumn' => 'id',
199 'labelColumn' => 'label',
200 'condition' => 'parent_id IS NULL',
201 ],
202 ],
203 'is_active' => [
204 'name' => 'is_active',
205 'type' => CRM_Utils_Type::T_BOOLEAN,
206 'title' => ts('Contact Type Is Active?'),
207 'description' => ts('Is this entry active?'),
208 'where' => 'civicrm_contact_type.is_active',
209 'table_name' => 'civicrm_contact_type',
210 'entity' => 'ContactType',
211 'bao' => 'CRM_Contact_BAO_ContactType',
212 'localizable' => 0,
213 ],
214 'is_reserved' => [
215 'name' => 'is_reserved',
216 'type' => CRM_Utils_Type::T_BOOLEAN,
217 'title' => ts('Contact Type is Reserved?'),
218 'description' => ts('Is this contact type a predefined system type'),
219 'where' => 'civicrm_contact_type.is_reserved',
220 'table_name' => 'civicrm_contact_type',
221 'entity' => 'ContactType',
222 'bao' => 'CRM_Contact_BAO_ContactType',
223 'localizable' => 0,
224 ],
225 ];
226 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
227 }
228 return Civi::$statics[__CLASS__]['fields'];
229 }
230
231 /**
232 * Return a mapping from field-name to the corresponding key (as used in fields()).
233 *
234 * @return array
235 * Array(string $name => string $uniqueName).
236 */
237 public static function &fieldKeys() {
238 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
239 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
240 }
241 return Civi::$statics[__CLASS__]['fieldKeys'];
242 }
243
244 /**
245 * Returns the names of this table
246 *
247 * @return string
248 */
249 public static function getTableName() {
250 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
251 }
252
253 /**
254 * Returns if this table needs to be logged
255 *
256 * @return bool
257 */
258 public function getLog() {
259 return self::$_log;
260 }
261
262 /**
263 * Returns the list of fields that can be imported
264 *
265 * @param bool $prefix
266 *
267 * @return array
268 */
269 public static function &import($prefix = FALSE) {
270 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contact_type', $prefix, []);
271 return $r;
272 }
273
274 /**
275 * Returns the list of fields that can be exported
276 *
277 * @param bool $prefix
278 *
279 * @return array
280 */
281 public static function &export($prefix = FALSE) {
282 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contact_type', $prefix, []);
283 return $r;
284 }
285
286 /**
287 * Returns the list of indices
288 *
289 * @param bool $localize
290 *
291 * @return array
292 */
293 public static function indices($localize = TRUE) {
294 $indices = [
295 'contact_type' => [
296 'name' => 'contact_type',
297 'field' => [
298 0 => 'name',
299 ],
300 'localizable' => FALSE,
301 'unique' => TRUE,
302 'sig' => 'civicrm_contact_type::1::name',
303 ],
304 ];
305 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
306 }
307
308 }