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