Add "labelField" metadata to entities
[civicrm-core.git] / CRM / Contact / DAO / RelationshipCache.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contact/RelationshipCache.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:b35c483041c2cf38afed94446977fa1e)
10 */
11
12 /**
13 * Database access object for the RelationshipCache entity.
14 */
15 class CRM_Contact_DAO_RelationshipCache extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '5.29';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_relationship_cache';
25
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-handshake-o';
32
33 /**
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
35 *
36 * @var bool
37 */
38 public static $_log = FALSE;
39
40 /**
41 * Relationship Cache ID
42 *
43 * @var int
44 */
45 public $id;
46
47 /**
48 * id of the relationship (FK to civicrm_relationship.id)
49 *
50 * @var int
51 */
52 public $relationship_id;
53
54 /**
55 * id of the relationship type
56 *
57 * @var int
58 */
59 public $relationship_type_id;
60
61 /**
62 * The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.
63 *
64 * @var string
65 */
66 public $orientation;
67
68 /**
69 * id of the first contact
70 *
71 * @var int
72 */
73 public $near_contact_id;
74
75 /**
76 * name for relationship of near_contact to far_contact.
77 *
78 * @var string
79 */
80 public $near_relation;
81
82 /**
83 * id of the second contact
84 *
85 * @var int
86 */
87 public $far_contact_id;
88
89 /**
90 * name for relationship of far_contact to near_contact.
91 *
92 * @var string
93 */
94 public $far_relation;
95
96 /**
97 * is the relationship active ?
98 *
99 * @var bool
100 */
101 public $is_active;
102
103 /**
104 * date when the relationship started
105 *
106 * @var date
107 */
108 public $start_date;
109
110 /**
111 * date when the relationship ended
112 *
113 * @var date
114 */
115 public $end_date;
116
117 /**
118 * Class constructor.
119 */
120 public function __construct() {
121 $this->__table = 'civicrm_relationship_cache';
122 parent::__construct();
123 }
124
125 /**
126 * Returns localized title of this entity.
127 *
128 * @param bool $plural
129 * Whether to return the plural version of the title.
130 */
131 public static function getEntityTitle($plural = FALSE) {
132 return $plural ? ts('Related Contacts') : ts('Related Contact');
133 }
134
135 /**
136 * Returns foreign keys and entity references.
137 *
138 * @return array
139 * [CRM_Core_Reference_Interface]
140 */
141 public static function getReferenceColumns() {
142 if (!isset(Civi::$statics[__CLASS__]['links'])) {
143 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
144 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
145 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
146 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'near_contact_id', 'civicrm_contact', 'id');
147 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'far_contact_id', 'civicrm_contact', 'id');
148 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
149 }
150 return Civi::$statics[__CLASS__]['links'];
151 }
152
153 /**
154 * Returns all the column names of this table
155 *
156 * @return array
157 */
158 public static function &fields() {
159 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
160 Civi::$statics[__CLASS__]['fields'] = [
161 'id' => [
162 'name' => 'id',
163 'type' => CRM_Utils_Type::T_INT,
164 'title' => ts('Relationship Cache ID'),
165 'description' => ts('Relationship Cache ID'),
166 'required' => TRUE,
167 'where' => 'civicrm_relationship_cache.id',
168 'table_name' => 'civicrm_relationship_cache',
169 'entity' => 'RelationshipCache',
170 'bao' => 'CRM_Contact_BAO_RelationshipCache',
171 'localizable' => 0,
172 'add' => '5.29',
173 ],
174 'relationship_id' => [
175 'name' => 'relationship_id',
176 'type' => CRM_Utils_Type::T_INT,
177 'title' => ts('Relationship'),
178 'description' => ts('id of the relationship (FK to civicrm_relationship.id)'),
179 'required' => TRUE,
180 'where' => 'civicrm_relationship_cache.relationship_id',
181 'table_name' => 'civicrm_relationship_cache',
182 'entity' => 'RelationshipCache',
183 'bao' => 'CRM_Contact_BAO_RelationshipCache',
184 'localizable' => 0,
185 'FKClassName' => 'CRM_Contact_DAO_Relationship',
186 'add' => '5.29',
187 ],
188 'relationship_type_id' => [
189 'name' => 'relationship_type_id',
190 'type' => CRM_Utils_Type::T_INT,
191 'title' => ts('Relationship Type'),
192 'description' => ts('id of the relationship type'),
193 'required' => TRUE,
194 'where' => 'civicrm_relationship_cache.relationship_type_id',
195 'table_name' => 'civicrm_relationship_cache',
196 'entity' => 'RelationshipCache',
197 'bao' => 'CRM_Contact_BAO_RelationshipCache',
198 'localizable' => 0,
199 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
200 'add' => '5.29',
201 ],
202 'orientation' => [
203 'name' => 'orientation',
204 'type' => CRM_Utils_Type::T_STRING,
205 'title' => ts('Orientation (a_b or b_a)'),
206 'description' => ts('The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.'),
207 'required' => TRUE,
208 'maxlength' => 3,
209 'size' => CRM_Utils_Type::FOUR,
210 'where' => 'civicrm_relationship_cache.orientation',
211 'table_name' => 'civicrm_relationship_cache',
212 'entity' => 'RelationshipCache',
213 'bao' => 'CRM_Contact_BAO_RelationshipCache',
214 'localizable' => 0,
215 'pseudoconstant' => [
216 'callback' => 'CRM_Core_SelectValues::relationshipOrientation',
217 ],
218 'add' => '5.29',
219 ],
220 'near_contact_id' => [
221 'name' => 'near_contact_id',
222 'type' => CRM_Utils_Type::T_INT,
223 'title' => ts('Contact ID (Near side)'),
224 'description' => ts('id of the first contact'),
225 'required' => TRUE,
226 'where' => 'civicrm_relationship_cache.near_contact_id',
227 'table_name' => 'civicrm_relationship_cache',
228 'entity' => 'RelationshipCache',
229 'bao' => 'CRM_Contact_BAO_RelationshipCache',
230 'localizable' => 0,
231 'FKClassName' => 'CRM_Contact_DAO_Contact',
232 'html' => [
233 'type' => 'EntityRef',
234 ],
235 'add' => '5.29',
236 ],
237 'near_relation' => [
238 'name' => 'near_relation',
239 'type' => CRM_Utils_Type::T_STRING,
240 'title' => ts('Relationship Name (to related contact)'),
241 'description' => ts('name for relationship of near_contact to far_contact.'),
242 'maxlength' => 64,
243 'size' => CRM_Utils_Type::BIG,
244 'where' => 'civicrm_relationship_cache.near_relation',
245 'table_name' => 'civicrm_relationship_cache',
246 'entity' => 'RelationshipCache',
247 'bao' => 'CRM_Contact_BAO_RelationshipCache',
248 'localizable' => 0,
249 'html' => [
250 'label' => ts("Relationship to contact"),
251 ],
252 'pseudoconstant' => [
253 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
254 ],
255 'add' => '5.29',
256 ],
257 'far_contact_id' => [
258 'name' => 'far_contact_id',
259 'type' => CRM_Utils_Type::T_INT,
260 'title' => ts('Contact ID (Far side)'),
261 'description' => ts('id of the second contact'),
262 'required' => TRUE,
263 'where' => 'civicrm_relationship_cache.far_contact_id',
264 'table_name' => 'civicrm_relationship_cache',
265 'entity' => 'RelationshipCache',
266 'bao' => 'CRM_Contact_BAO_RelationshipCache',
267 'localizable' => 0,
268 'FKClassName' => 'CRM_Contact_DAO_Contact',
269 'html' => [
270 'type' => 'EntityRef',
271 ],
272 'add' => '5.29',
273 ],
274 'far_relation' => [
275 'name' => 'far_relation',
276 'type' => CRM_Utils_Type::T_STRING,
277 'title' => ts('Relationship Name (from related contact)'),
278 'description' => ts('name for relationship of far_contact to near_contact.'),
279 'maxlength' => 64,
280 'size' => CRM_Utils_Type::BIG,
281 'where' => 'civicrm_relationship_cache.far_relation',
282 'table_name' => 'civicrm_relationship_cache',
283 'entity' => 'RelationshipCache',
284 'bao' => 'CRM_Contact_BAO_RelationshipCache',
285 'localizable' => 0,
286 'html' => [
287 'label' => ts("Relationship from contact"),
288 ],
289 'pseudoconstant' => [
290 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
291 ],
292 'add' => '5.29',
293 ],
294 'is_active' => [
295 'name' => 'is_active',
296 'type' => CRM_Utils_Type::T_BOOLEAN,
297 'title' => ts('Relationship Is Active'),
298 'description' => ts('is the relationship active ?'),
299 'where' => 'civicrm_relationship_cache.is_active',
300 'default' => '1',
301 'table_name' => 'civicrm_relationship_cache',
302 'entity' => 'RelationshipCache',
303 'bao' => 'CRM_Contact_BAO_RelationshipCache',
304 'localizable' => 0,
305 'html' => [
306 'type' => 'CheckBox',
307 ],
308 'add' => '5.29',
309 ],
310 'relationship_start_date' => [
311 'name' => 'start_date',
312 'type' => CRM_Utils_Type::T_DATE,
313 'title' => ts('Relationship Start Date'),
314 'description' => ts('date when the relationship started'),
315 'where' => 'civicrm_relationship_cache.start_date',
316 'table_name' => 'civicrm_relationship_cache',
317 'entity' => 'RelationshipCache',
318 'bao' => 'CRM_Contact_BAO_RelationshipCache',
319 'localizable' => 0,
320 'html' => [
321 'type' => 'Select Date',
322 'formatType' => 'activityDate',
323 ],
324 'add' => '5.29',
325 ],
326 'relationship_end_date' => [
327 'name' => 'end_date',
328 'type' => CRM_Utils_Type::T_DATE,
329 'title' => ts('Relationship End Date'),
330 'description' => ts('date when the relationship ended'),
331 'where' => 'civicrm_relationship_cache.end_date',
332 'table_name' => 'civicrm_relationship_cache',
333 'entity' => 'RelationshipCache',
334 'bao' => 'CRM_Contact_BAO_RelationshipCache',
335 'localizable' => 0,
336 'html' => [
337 'type' => 'Select Date',
338 'formatType' => 'activityDate',
339 ],
340 'add' => '5.29',
341 ],
342 ];
343 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
344 }
345 return Civi::$statics[__CLASS__]['fields'];
346 }
347
348 /**
349 * Return a mapping from field-name to the corresponding key (as used in fields()).
350 *
351 * @return array
352 * Array(string $name => string $uniqueName).
353 */
354 public static function &fieldKeys() {
355 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
356 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
357 }
358 return Civi::$statics[__CLASS__]['fieldKeys'];
359 }
360
361 /**
362 * Returns the names of this table
363 *
364 * @return string
365 */
366 public static function getTableName() {
367 return self::$_tableName;
368 }
369
370 /**
371 * Returns if this table needs to be logged
372 *
373 * @return bool
374 */
375 public function getLog() {
376 return self::$_log;
377 }
378
379 /**
380 * Returns the list of fields that can be imported
381 *
382 * @param bool $prefix
383 *
384 * @return array
385 */
386 public static function &import($prefix = FALSE) {
387 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship_cache', $prefix, []);
388 return $r;
389 }
390
391 /**
392 * Returns the list of fields that can be exported
393 *
394 * @param bool $prefix
395 *
396 * @return array
397 */
398 public static function &export($prefix = FALSE) {
399 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship_cache', $prefix, []);
400 return $r;
401 }
402
403 /**
404 * Returns the list of indices
405 *
406 * @param bool $localize
407 *
408 * @return array
409 */
410 public static function indices($localize = TRUE) {
411 $indices = [
412 'UI_relationship' => [
413 'name' => 'UI_relationship',
414 'field' => [
415 0 => 'relationship_id',
416 1 => 'orientation',
417 ],
418 'localizable' => FALSE,
419 'unique' => TRUE,
420 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
421 ],
422 'index_nearid_nearrelation' => [
423 'name' => 'index_nearid_nearrelation',
424 'field' => [
425 0 => 'near_contact_id',
426 1 => 'near_relation',
427 ],
428 'localizable' => FALSE,
429 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
430 ],
431 'index_nearid_farrelation' => [
432 'name' => 'index_nearid_farrelation',
433 'field' => [
434 0 => 'near_contact_id',
435 1 => 'far_relation',
436 ],
437 'localizable' => FALSE,
438 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
439 ],
440 'index_near_relation' => [
441 'name' => 'index_near_relation',
442 'field' => [
443 0 => 'near_relation',
444 ],
445 'localizable' => FALSE,
446 'sig' => 'civicrm_relationship_cache::0::near_relation',
447 ],
448 ];
449 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
450 }
451
452 }