DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / Mailing / Event / DAO / Queue.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/Queue.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:f37d1a6e35b4f827ed7daf29b3005fad)
10 */
11
12 /**
13 * Database access object for the Queue entity.
14 */
15 class CRM_Mailing_Event_DAO_Queue 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_queue';
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 Job
40 *
41 * @var int
42 */
43 public $job_id;
44
45 /**
46 * FK to Email
47 *
48 * @var int
49 */
50 public $email_id;
51
52 /**
53 * FK to Contact
54 *
55 * @var int
56 */
57 public $contact_id;
58
59 /**
60 * Security hash
61 *
62 * @var string
63 */
64 public $hash;
65
66 /**
67 * FK to Phone
68 *
69 * @var int
70 */
71 public $phone_id;
72
73 /**
74 * Class constructor.
75 */
76 public function __construct() {
77 $this->__table = 'civicrm_mailing_event_queue';
78 parent::__construct();
79 }
80
81 /**
82 * Returns localized title of this entity.
83 *
84 * @param bool $plural
85 * Whether to return the plural version of the title.
86 */
87 public static function getEntityTitle($plural = FALSE) {
88 return $plural ? ts('Queues') : ts('Queue');
89 }
90
91 /**
92 * Returns foreign keys and entity references.
93 *
94 * @return array
95 * [CRM_Core_Reference_Interface]
96 */
97 public static function getReferenceColumns() {
98 if (!isset(Civi::$statics[__CLASS__]['links'])) {
99 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
100 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'job_id', 'civicrm_mailing_job', 'id');
101 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'email_id', 'civicrm_email', 'id');
102 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
103 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'phone_id', 'civicrm_phone', 'id');
104 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
105 }
106 return Civi::$statics[__CLASS__]['links'];
107 }
108
109 /**
110 * Returns all the column names of this table
111 *
112 * @return array
113 */
114 public static function &fields() {
115 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
116 Civi::$statics[__CLASS__]['fields'] = [
117 'id' => [
118 'name' => 'id',
119 'type' => CRM_Utils_Type::T_INT,
120 'title' => ts('Mailing Event Queue ID'),
121 'required' => TRUE,
122 'where' => 'civicrm_mailing_event_queue.id',
123 'table_name' => 'civicrm_mailing_event_queue',
124 'entity' => 'Queue',
125 'bao' => 'CRM_Mailing_Event_BAO_Queue',
126 'localizable' => 0,
127 'add' => NULL,
128 ],
129 'job_id' => [
130 'name' => 'job_id',
131 'type' => CRM_Utils_Type::T_INT,
132 'title' => ts('Job ID'),
133 'description' => ts('FK to Job'),
134 'required' => TRUE,
135 'where' => 'civicrm_mailing_event_queue.job_id',
136 'table_name' => 'civicrm_mailing_event_queue',
137 'entity' => 'Queue',
138 'bao' => 'CRM_Mailing_Event_BAO_Queue',
139 'localizable' => 0,
140 'FKClassName' => 'CRM_Mailing_DAO_MailingJob',
141 'add' => NULL,
142 ],
143 'email_id' => [
144 'name' => 'email_id',
145 'type' => CRM_Utils_Type::T_INT,
146 'title' => ts('Email ID'),
147 'description' => ts('FK to Email'),
148 'where' => 'civicrm_mailing_event_queue.email_id',
149 'default' => 'NULL',
150 'table_name' => 'civicrm_mailing_event_queue',
151 'entity' => 'Queue',
152 'bao' => 'CRM_Mailing_Event_BAO_Queue',
153 'localizable' => 0,
154 'FKClassName' => 'CRM_Core_DAO_Email',
155 'add' => NULL,
156 ],
157 'contact_id' => [
158 'name' => 'contact_id',
159 'type' => CRM_Utils_Type::T_INT,
160 'title' => ts('Contact ID'),
161 'description' => ts('FK to Contact'),
162 'required' => TRUE,
163 'where' => 'civicrm_mailing_event_queue.contact_id',
164 'table_name' => 'civicrm_mailing_event_queue',
165 'entity' => 'Queue',
166 'bao' => 'CRM_Mailing_Event_BAO_Queue',
167 'localizable' => 0,
168 'FKClassName' => 'CRM_Contact_DAO_Contact',
169 'add' => NULL,
170 ],
171 'hash' => [
172 'name' => 'hash',
173 'type' => CRM_Utils_Type::T_STRING,
174 'title' => ts('Security Hash'),
175 'description' => ts('Security hash'),
176 'required' => TRUE,
177 'maxlength' => 255,
178 'size' => CRM_Utils_Type::HUGE,
179 'where' => 'civicrm_mailing_event_queue.hash',
180 'table_name' => 'civicrm_mailing_event_queue',
181 'entity' => 'Queue',
182 'bao' => 'CRM_Mailing_Event_BAO_Queue',
183 'localizable' => 0,
184 'add' => NULL,
185 ],
186 'phone_id' => [
187 'name' => 'phone_id',
188 'type' => CRM_Utils_Type::T_INT,
189 'title' => ts('Phone ID'),
190 'description' => ts('FK to Phone'),
191 'where' => 'civicrm_mailing_event_queue.phone_id',
192 'default' => 'NULL',
193 'table_name' => 'civicrm_mailing_event_queue',
194 'entity' => 'Queue',
195 'bao' => 'CRM_Mailing_Event_BAO_Queue',
196 'localizable' => 0,
197 'FKClassName' => 'CRM_Core_DAO_Phone',
198 'add' => NULL,
199 ],
200 ];
201 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
202 }
203 return Civi::$statics[__CLASS__]['fields'];
204 }
205
206 /**
207 * Return a mapping from field-name to the corresponding key (as used in fields()).
208 *
209 * @return array
210 * Array(string $name => string $uniqueName).
211 */
212 public static function &fieldKeys() {
213 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
214 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
215 }
216 return Civi::$statics[__CLASS__]['fieldKeys'];
217 }
218
219 /**
220 * Returns the names of this table
221 *
222 * @return string
223 */
224 public static function getTableName() {
225 return self::$_tableName;
226 }
227
228 /**
229 * Returns if this table needs to be logged
230 *
231 * @return bool
232 */
233 public function getLog() {
234 return self::$_log;
235 }
236
237 /**
238 * Returns the list of fields that can be imported
239 *
240 * @param bool $prefix
241 *
242 * @return array
243 */
244 public static function &import($prefix = FALSE) {
245 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_queue', $prefix, []);
246 return $r;
247 }
248
249 /**
250 * Returns the list of fields that can be exported
251 *
252 * @param bool $prefix
253 *
254 * @return array
255 */
256 public static function &export($prefix = FALSE) {
257 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_queue', $prefix, []);
258 return $r;
259 }
260
261 /**
262 * Returns the list of indices
263 *
264 * @param bool $localize
265 *
266 * @return array
267 */
268 public static function indices($localize = TRUE) {
269 $indices = [
270 'index_hash' => [
271 'name' => 'index_hash',
272 'field' => [
273 0 => 'hash',
274 ],
275 'localizable' => FALSE,
276 'sig' => 'civicrm_mailing_event_queue::0::hash',
277 ],
278 ];
279 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
280 }
281
282 }