[NFC] Minor code cleanup
[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:773c4e4cbe66d404e30e3dffa2dcb8a1)
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 ],
103 'group_id' => [
104 'name' => 'group_id',
105 'type' => CRM_Utils_Type::T_INT,
106 'title' => ts('Group'),
107 'description' => ts('FK to civicrm_group'),
108 'required' => TRUE,
109 'where' => 'civicrm_group_contact_cache.group_id',
110 'table_name' => 'civicrm_group_contact_cache',
111 'entity' => 'GroupContactCache',
112 'bao' => 'CRM_Contact_BAO_GroupContactCache',
113 'localizable' => 0,
114 'FKClassName' => 'CRM_Contact_DAO_Group',
115 'html' => [
116 'type' => 'Select',
117 ],
118 'pseudoconstant' => [
119 'table' => 'civicrm_group',
120 'keyColumn' => 'id',
121 'labelColumn' => 'title',
122 ],
123 ],
124 'contact_id' => [
125 'name' => 'contact_id',
126 'type' => CRM_Utils_Type::T_INT,
127 'title' => ts('Contact ID'),
128 'description' => ts('FK to civicrm_contact'),
129 'required' => TRUE,
130 'where' => 'civicrm_group_contact_cache.contact_id',
131 'table_name' => 'civicrm_group_contact_cache',
132 'entity' => 'GroupContactCache',
133 'bao' => 'CRM_Contact_BAO_GroupContactCache',
134 'localizable' => 0,
135 'FKClassName' => 'CRM_Contact_DAO_Contact',
136 ],
137 ];
138 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
139 }
140 return Civi::$statics[__CLASS__]['fields'];
141 }
142
143 /**
144 * Return a mapping from field-name to the corresponding key (as used in fields()).
145 *
146 * @return array
147 * Array(string $name => string $uniqueName).
148 */
149 public static function &fieldKeys() {
150 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
151 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
152 }
153 return Civi::$statics[__CLASS__]['fieldKeys'];
154 }
155
156 /**
157 * Returns the names of this table
158 *
159 * @return string
160 */
161 public static function getTableName() {
162 return self::$_tableName;
163 }
164
165 /**
166 * Returns if this table needs to be logged
167 *
168 * @return bool
169 */
170 public function getLog() {
171 return self::$_log;
172 }
173
174 /**
175 * Returns the list of fields that can be imported
176 *
177 * @param bool $prefix
178 *
179 * @return array
180 */
181 public static function &import($prefix = FALSE) {
182 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group_contact_cache', $prefix, []);
183 return $r;
184 }
185
186 /**
187 * Returns the list of fields that can be exported
188 *
189 * @param bool $prefix
190 *
191 * @return array
192 */
193 public static function &export($prefix = FALSE) {
194 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group_contact_cache', $prefix, []);
195 return $r;
196 }
197
198 /**
199 * Returns the list of indices
200 *
201 * @param bool $localize
202 *
203 * @return array
204 */
205 public static function indices($localize = TRUE) {
206 $indices = [
207 'UI_contact_group' => [
208 'name' => 'UI_contact_group',
209 'field' => [
210 0 => 'contact_id',
211 1 => 'group_id',
212 ],
213 'localizable' => FALSE,
214 'unique' => TRUE,
215 'sig' => 'civicrm_group_contact_cache::1::contact_id::group_id',
216 ],
217 ];
218 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
219 }
220
221 }