API/DAO Metadata - Retain versioning metadata for possible usage in runtime+tooling
[civicrm-core.git] / CRM / Contact / DAO / GroupContactCache.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contact/GroupContactCache.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:78446b0939b21d995dd17476d11030e7)
10 */
11
12 /**
13 * Database access object for the GroupContactCache entity.
14 */
15 class CRM_Contact_DAO_GroupContactCache extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_group_contact_cache';
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 * primary key
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * FK to civicrm_group
40 *
41 * @var int
42 */
43 public $group_id;
44
45 /**
46 * FK to civicrm_contact
47 *
48 * @var int
49 */
50 public $contact_id;
51
52 /**
53 * Class constructor.
54 */
55 public function __construct() {
56 $this->__table = 'civicrm_group_contact_cache';
57 parent::__construct();
58 }
59
60 /**
61 * Returns localized title of this entity.
62 */
63 public static function getEntityTitle() {
64 return ts('Group Contact Caches');
65 }
66
67 /**
68 * Returns foreign keys and entity references.
69 *
70 * @return array
71 * [CRM_Core_Reference_Interface]
72 */
73 public static function getReferenceColumns() {
74 if (!isset(Civi::$statics[__CLASS__]['links'])) {
75 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
76 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
77 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
78 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
79 }
80 return Civi::$statics[__CLASS__]['links'];
81 }
82
83 /**
84 * Returns all the column names of this table
85 *
86 * @return array
87 */
88 public static function &fields() {
89 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
90 Civi::$statics[__CLASS__]['fields'] = [
91 'id' => [
92 'name' => 'id',
93 'type' => CRM_Utils_Type::T_INT,
94 'title' => ts('Group Contact Cache ID'),
95 'description' => ts('primary key'),
96 'required' => TRUE,
97 'where' => 'civicrm_group_contact_cache.id',
98 'table_name' => 'civicrm_group_contact_cache',
99 'entity' => 'GroupContactCache',
100 'bao' => 'CRM_Contact_BAO_GroupContactCache',
101 'localizable' => 0,
102 'add' => '2.1',
103 ],
104 'group_id' => [
105 'name' => 'group_id',
106 'type' => CRM_Utils_Type::T_INT,
107 'title' => ts('Group'),
108 'description' => ts('FK to civicrm_group'),
109 'required' => TRUE,
110 'where' => 'civicrm_group_contact_cache.group_id',
111 'table_name' => 'civicrm_group_contact_cache',
112 'entity' => 'GroupContactCache',
113 'bao' => 'CRM_Contact_BAO_GroupContactCache',
114 'localizable' => 0,
115 'FKClassName' => 'CRM_Contact_DAO_Group',
116 'html' => [
117 'type' => 'Select',
118 ],
119 'pseudoconstant' => [
120 'table' => 'civicrm_group',
121 'keyColumn' => 'id',
122 'labelColumn' => 'title',
123 ],
124 'add' => '2.1',
125 ],
126 'contact_id' => [
127 'name' => 'contact_id',
128 'type' => CRM_Utils_Type::T_INT,
129 'title' => ts('Contact ID'),
130 'description' => ts('FK to civicrm_contact'),
131 'required' => TRUE,
132 'where' => 'civicrm_group_contact_cache.contact_id',
133 'table_name' => 'civicrm_group_contact_cache',
134 'entity' => 'GroupContactCache',
135 'bao' => 'CRM_Contact_BAO_GroupContactCache',
136 'localizable' => 0,
137 'FKClassName' => 'CRM_Contact_DAO_Contact',
138 'add' => '2.1',
139 ],
140 ];
141 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
142 }
143 return Civi::$statics[__CLASS__]['fields'];
144 }
145
146 /**
147 * Return a mapping from field-name to the corresponding key (as used in fields()).
148 *
149 * @return array
150 * Array(string $name => string $uniqueName).
151 */
152 public static function &fieldKeys() {
153 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
154 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
155 }
156 return Civi::$statics[__CLASS__]['fieldKeys'];
157 }
158
159 /**
160 * Returns the names of this table
161 *
162 * @return string
163 */
164 public static function getTableName() {
165 return self::$_tableName;
166 }
167
168 /**
169 * Returns if this table needs to be logged
170 *
171 * @return bool
172 */
173 public function getLog() {
174 return self::$_log;
175 }
176
177 /**
178 * Returns the list of fields that can be imported
179 *
180 * @param bool $prefix
181 *
182 * @return array
183 */
184 public static function &import($prefix = FALSE) {
185 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group_contact_cache', $prefix, []);
186 return $r;
187 }
188
189 /**
190 * Returns the list of fields that can be exported
191 *
192 * @param bool $prefix
193 *
194 * @return array
195 */
196 public static function &export($prefix = FALSE) {
197 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group_contact_cache', $prefix, []);
198 return $r;
199 }
200
201 /**
202 * Returns the list of indices
203 *
204 * @param bool $localize
205 *
206 * @return array
207 */
208 public static function indices($localize = TRUE) {
209 $indices = [
210 'UI_contact_group' => [
211 'name' => 'UI_contact_group',
212 'field' => [
213 0 => 'contact_id',
214 1 => 'group_id',
215 ],
216 'localizable' => FALSE,
217 'unique' => TRUE,
218 'sig' => 'civicrm_group_contact_cache::1::contact_id::group_id',
219 ],
220 ];
221 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
222 }
223
224 }