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