Add "labelField" metadata to entities
[civicrm-core.git] / CRM / Mailing / Event / DAO / Subscribe.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Mailing/Event/Subscribe.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:e327b7f0c61b9955118127b1cc81df13)
10 */
11
12 /**
13 * Database access object for the Subscribe entity.
14 */
15 class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '';
18 const COMPONENT = 'CiviMail';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_mailing_event_subscribe';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = FALSE;
33
34 /**
35 * @var int
36 */
37 public $id;
38
39 /**
40 * FK to Group
41 *
42 * @var int
43 */
44 public $group_id;
45
46 /**
47 * FK to Contact
48 *
49 * @var int
50 */
51 public $contact_id;
52
53 /**
54 * Security hash
55 *
56 * @var string
57 */
58 public $hash;
59
60 /**
61 * When this subscription event occurred.
62 *
63 * @var timestamp
64 */
65 public $time_stamp;
66
67 /**
68 * Class constructor.
69 */
70 public function __construct() {
71 $this->__table = 'civicrm_mailing_event_subscribe';
72 parent::__construct();
73 }
74
75 /**
76 * Returns localized title of this entity.
77 *
78 * @param bool $plural
79 * Whether to return the plural version of the title.
80 */
81 public static function getEntityTitle($plural = FALSE) {
82 return $plural ? ts('Subscribes') : ts('Subscribe');
83 }
84
85 /**
86 * Returns foreign keys and entity references.
87 *
88 * @return array
89 * [CRM_Core_Reference_Interface]
90 */
91 public static function getReferenceColumns() {
92 if (!isset(Civi::$statics[__CLASS__]['links'])) {
93 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
94 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
95 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
96 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
97 }
98 return Civi::$statics[__CLASS__]['links'];
99 }
100
101 /**
102 * Returns all the column names of this table
103 *
104 * @return array
105 */
106 public static function &fields() {
107 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
108 Civi::$statics[__CLASS__]['fields'] = [
109 'id' => [
110 'name' => 'id',
111 'type' => CRM_Utils_Type::T_INT,
112 'title' => ts('Mailing Subscribe ID'),
113 'required' => TRUE,
114 'where' => 'civicrm_mailing_event_subscribe.id',
115 'table_name' => 'civicrm_mailing_event_subscribe',
116 'entity' => 'Subscribe',
117 'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
118 'localizable' => 0,
119 'add' => NULL,
120 ],
121 'group_id' => [
122 'name' => 'group_id',
123 'type' => CRM_Utils_Type::T_INT,
124 'title' => ts('Mailing Subscribe Group'),
125 'description' => ts('FK to Group'),
126 'required' => TRUE,
127 'where' => 'civicrm_mailing_event_subscribe.group_id',
128 'table_name' => 'civicrm_mailing_event_subscribe',
129 'entity' => 'Subscribe',
130 'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
131 'localizable' => 0,
132 'FKClassName' => 'CRM_Contact_DAO_Group',
133 'html' => [
134 'type' => 'Select',
135 ],
136 'pseudoconstant' => [
137 'table' => 'civicrm_group',
138 'keyColumn' => 'id',
139 'labelColumn' => 'title',
140 ],
141 'add' => NULL,
142 ],
143 'contact_id' => [
144 'name' => 'contact_id',
145 'type' => CRM_Utils_Type::T_INT,
146 'title' => ts('Mailing Subscribe Contact'),
147 'description' => ts('FK to Contact'),
148 'required' => TRUE,
149 'where' => 'civicrm_mailing_event_subscribe.contact_id',
150 'table_name' => 'civicrm_mailing_event_subscribe',
151 'entity' => 'Subscribe',
152 'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
153 'localizable' => 0,
154 'FKClassName' => 'CRM_Contact_DAO_Contact',
155 'add' => NULL,
156 ],
157 'hash' => [
158 'name' => 'hash',
159 'type' => CRM_Utils_Type::T_STRING,
160 'title' => ts('Mailing Subscribe Hash'),
161 'description' => ts('Security hash'),
162 'required' => TRUE,
163 'maxlength' => 255,
164 'size' => CRM_Utils_Type::HUGE,
165 'where' => 'civicrm_mailing_event_subscribe.hash',
166 'table_name' => 'civicrm_mailing_event_subscribe',
167 'entity' => 'Subscribe',
168 'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
169 'localizable' => 0,
170 'add' => NULL,
171 ],
172 'time_stamp' => [
173 'name' => 'time_stamp',
174 'type' => CRM_Utils_Type::T_TIMESTAMP,
175 'title' => ts('Mailing Subscribe Timestamp'),
176 'description' => ts('When this subscription event occurred.'),
177 'required' => TRUE,
178 'where' => 'civicrm_mailing_event_subscribe.time_stamp',
179 'default' => 'CURRENT_TIMESTAMP',
180 'table_name' => 'civicrm_mailing_event_subscribe',
181 'entity' => 'Subscribe',
182 'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
183 'localizable' => 0,
184 'add' => NULL,
185 ],
186 ];
187 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
188 }
189 return Civi::$statics[__CLASS__]['fields'];
190 }
191
192 /**
193 * Return a mapping from field-name to the corresponding key (as used in fields()).
194 *
195 * @return array
196 * Array(string $name => string $uniqueName).
197 */
198 public static function &fieldKeys() {
199 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
200 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
201 }
202 return Civi::$statics[__CLASS__]['fieldKeys'];
203 }
204
205 /**
206 * Returns the names of this table
207 *
208 * @return string
209 */
210 public static function getTableName() {
211 return self::$_tableName;
212 }
213
214 /**
215 * Returns if this table needs to be logged
216 *
217 * @return bool
218 */
219 public function getLog() {
220 return self::$_log;
221 }
222
223 /**
224 * Returns the list of fields that can be imported
225 *
226 * @param bool $prefix
227 *
228 * @return array
229 */
230 public static function &import($prefix = FALSE) {
231 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_subscribe', $prefix, []);
232 return $r;
233 }
234
235 /**
236 * Returns the list of fields that can be exported
237 *
238 * @param bool $prefix
239 *
240 * @return array
241 */
242 public static function &export($prefix = FALSE) {
243 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_subscribe', $prefix, []);
244 return $r;
245 }
246
247 /**
248 * Returns the list of indices
249 *
250 * @param bool $localize
251 *
252 * @return array
253 */
254 public static function indices($localize = TRUE) {
255 $indices = [];
256 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
257 }
258
259 }