DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / Financial / DAO / PaymentToken.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Financial/PaymentToken.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:2923b7966bbe25d435eb7b909d35541f)
10 */
11
12 /**
13 * Database access object for the PaymentToken entity.
14 */
15 class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.6';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_payment_token';
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 * Payment Token ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * FK to Contact ID for the owner of the token
42 *
43 * @var int
44 */
45 public $contact_id;
46
47 /**
48 * @var int
49 */
50 public $payment_processor_id;
51
52 /**
53 * Externally provided token string
54 *
55 * @var string
56 */
57 public $token;
58
59 /**
60 * Date created
61 *
62 * @var timestamp
63 */
64 public $created_date;
65
66 /**
67 * Contact ID of token creator
68 *
69 * @var int
70 */
71 public $created_id;
72
73 /**
74 * Date this token expires
75 *
76 * @var datetime
77 */
78 public $expiry_date;
79
80 /**
81 * Email at the time of token creation. Useful for fraud forensics
82 *
83 * @var string
84 */
85 public $email;
86
87 /**
88 * Billing first name at the time of token creation. Useful for fraud forensics
89 *
90 * @var string
91 */
92 public $billing_first_name;
93
94 /**
95 * Billing middle name at the time of token creation. Useful for fraud forensics
96 *
97 * @var string
98 */
99 public $billing_middle_name;
100
101 /**
102 * Billing last name at the time of token creation. Useful for fraud forensics
103 *
104 * @var string
105 */
106 public $billing_last_name;
107
108 /**
109 * Holds the part of the card number or account details that may be retained or displayed
110 *
111 * @var string
112 */
113 public $masked_account_number;
114
115 /**
116 * IP used when creating the token. Useful for fraud forensics
117 *
118 * @var string
119 */
120 public $ip_address;
121
122 /**
123 * Class constructor.
124 */
125 public function __construct() {
126 $this->__table = 'civicrm_payment_token';
127 parent::__construct();
128 }
129
130 /**
131 * Returns localized title of this entity.
132 *
133 * @param bool $plural
134 * Whether to return the plural version of the title.
135 */
136 public static function getEntityTitle($plural = FALSE) {
137 return $plural ? ts('Payment Tokens') : ts('Payment Token');
138 }
139
140 /**
141 * Returns foreign keys and entity references.
142 *
143 * @return array
144 * [CRM_Core_Reference_Interface]
145 */
146 public static function getReferenceColumns() {
147 if (!isset(Civi::$statics[__CLASS__]['links'])) {
148 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
149 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
150 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
151 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
152 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
153 }
154 return Civi::$statics[__CLASS__]['links'];
155 }
156
157 /**
158 * Returns all the column names of this table
159 *
160 * @return array
161 */
162 public static function &fields() {
163 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
164 Civi::$statics[__CLASS__]['fields'] = [
165 'payment_token_id' => [
166 'name' => 'id',
167 'type' => CRM_Utils_Type::T_INT,
168 'title' => ts('Payment Token ID'),
169 'description' => ts('Payment Token ID'),
170 'required' => TRUE,
171 'where' => 'civicrm_payment_token.id',
172 'table_name' => 'civicrm_payment_token',
173 'entity' => 'PaymentToken',
174 'bao' => 'CRM_Financial_DAO_PaymentToken',
175 'localizable' => 0,
176 'add' => '4.6',
177 ],
178 'contact_id' => [
179 'name' => 'contact_id',
180 'type' => CRM_Utils_Type::T_INT,
181 'title' => ts('Contact ID'),
182 'description' => ts('FK to Contact ID for the owner of the token'),
183 'required' => TRUE,
184 'where' => 'civicrm_payment_token.contact_id',
185 'table_name' => 'civicrm_payment_token',
186 'entity' => 'PaymentToken',
187 'bao' => 'CRM_Financial_DAO_PaymentToken',
188 'localizable' => 0,
189 'FKClassName' => 'CRM_Contact_DAO_Contact',
190 'add' => '4.6',
191 ],
192 'payment_processor_id' => [
193 'name' => 'payment_processor_id',
194 'type' => CRM_Utils_Type::T_INT,
195 'title' => ts('Payment Processor ID'),
196 'required' => TRUE,
197 'where' => 'civicrm_payment_token.payment_processor_id',
198 'table_name' => 'civicrm_payment_token',
199 'entity' => 'PaymentToken',
200 'bao' => 'CRM_Financial_DAO_PaymentToken',
201 'localizable' => 0,
202 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
203 'add' => '4.6',
204 ],
205 'token' => [
206 'name' => 'token',
207 'type' => CRM_Utils_Type::T_STRING,
208 'title' => ts('Token'),
209 'description' => ts('Externally provided token string'),
210 'required' => TRUE,
211 'maxlength' => 255,
212 'size' => CRM_Utils_Type::HUGE,
213 'where' => 'civicrm_payment_token.token',
214 'table_name' => 'civicrm_payment_token',
215 'entity' => 'PaymentToken',
216 'bao' => 'CRM_Financial_DAO_PaymentToken',
217 'localizable' => 0,
218 'add' => '4.6',
219 ],
220 'created_date' => [
221 'name' => 'created_date',
222 'type' => CRM_Utils_Type::T_TIMESTAMP,
223 'title' => ts('Created Date'),
224 'description' => ts('Date created'),
225 'where' => 'civicrm_payment_token.created_date',
226 'default' => 'CURRENT_TIMESTAMP',
227 'table_name' => 'civicrm_payment_token',
228 'entity' => 'PaymentToken',
229 'bao' => 'CRM_Financial_DAO_PaymentToken',
230 'localizable' => 0,
231 'add' => '4.6',
232 ],
233 'created_id' => [
234 'name' => 'created_id',
235 'type' => CRM_Utils_Type::T_INT,
236 'title' => ts('Created ID'),
237 'description' => ts('Contact ID of token creator'),
238 'where' => 'civicrm_payment_token.created_id',
239 'table_name' => 'civicrm_payment_token',
240 'entity' => 'PaymentToken',
241 'bao' => 'CRM_Financial_DAO_PaymentToken',
242 'localizable' => 0,
243 'FKClassName' => 'CRM_Contact_DAO_Contact',
244 'add' => '4.6',
245 ],
246 'expiry_date' => [
247 'name' => 'expiry_date',
248 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
249 'title' => ts('Expiry Date'),
250 'description' => ts('Date this token expires'),
251 'where' => 'civicrm_payment_token.expiry_date',
252 'table_name' => 'civicrm_payment_token',
253 'entity' => 'PaymentToken',
254 'bao' => 'CRM_Financial_DAO_PaymentToken',
255 'localizable' => 0,
256 'add' => '4.6',
257 ],
258 'email' => [
259 'name' => 'email',
260 'type' => CRM_Utils_Type::T_STRING,
261 'title' => ts('Email'),
262 'description' => ts('Email at the time of token creation. Useful for fraud forensics'),
263 'maxlength' => 255,
264 'size' => CRM_Utils_Type::HUGE,
265 'where' => 'civicrm_payment_token.email',
266 'table_name' => 'civicrm_payment_token',
267 'entity' => 'PaymentToken',
268 'bao' => 'CRM_Financial_DAO_PaymentToken',
269 'localizable' => 0,
270 'add' => '4.6',
271 ],
272 'billing_first_name' => [
273 'name' => 'billing_first_name',
274 'type' => CRM_Utils_Type::T_STRING,
275 'title' => ts('Billing First Name'),
276 'description' => ts('Billing first name at the time of token creation. Useful for fraud forensics'),
277 'maxlength' => 255,
278 'size' => CRM_Utils_Type::HUGE,
279 'where' => 'civicrm_payment_token.billing_first_name',
280 'table_name' => 'civicrm_payment_token',
281 'entity' => 'PaymentToken',
282 'bao' => 'CRM_Financial_DAO_PaymentToken',
283 'localizable' => 0,
284 'add' => '4.6',
285 ],
286 'billing_middle_name' => [
287 'name' => 'billing_middle_name',
288 'type' => CRM_Utils_Type::T_STRING,
289 'title' => ts('Billing Middle Name'),
290 'description' => ts('Billing middle name at the time of token creation. Useful for fraud forensics'),
291 'maxlength' => 255,
292 'size' => CRM_Utils_Type::HUGE,
293 'where' => 'civicrm_payment_token.billing_middle_name',
294 'table_name' => 'civicrm_payment_token',
295 'entity' => 'PaymentToken',
296 'bao' => 'CRM_Financial_DAO_PaymentToken',
297 'localizable' => 0,
298 'add' => '4.6',
299 ],
300 'billing_last_name' => [
301 'name' => 'billing_last_name',
302 'type' => CRM_Utils_Type::T_STRING,
303 'title' => ts('Billing Last Name'),
304 'description' => ts('Billing last name at the time of token creation. Useful for fraud forensics'),
305 'maxlength' => 255,
306 'size' => CRM_Utils_Type::HUGE,
307 'where' => 'civicrm_payment_token.billing_last_name',
308 'table_name' => 'civicrm_payment_token',
309 'entity' => 'PaymentToken',
310 'bao' => 'CRM_Financial_DAO_PaymentToken',
311 'localizable' => 0,
312 'add' => '4.6',
313 ],
314 'masked_account_number' => [
315 'name' => 'masked_account_number',
316 'type' => CRM_Utils_Type::T_STRING,
317 'title' => ts('Masked Account Number'),
318 'description' => ts('Holds the part of the card number or account details that may be retained or displayed'),
319 'maxlength' => 255,
320 'size' => CRM_Utils_Type::HUGE,
321 'where' => 'civicrm_payment_token.masked_account_number',
322 'table_name' => 'civicrm_payment_token',
323 'entity' => 'PaymentToken',
324 'bao' => 'CRM_Financial_DAO_PaymentToken',
325 'localizable' => 0,
326 'add' => '4.6',
327 ],
328 'ip_address' => [
329 'name' => 'ip_address',
330 'type' => CRM_Utils_Type::T_STRING,
331 'title' => ts('IP Address'),
332 'description' => ts('IP used when creating the token. Useful for fraud forensics'),
333 'maxlength' => 255,
334 'size' => CRM_Utils_Type::HUGE,
335 'where' => 'civicrm_payment_token.ip_address',
336 'table_name' => 'civicrm_payment_token',
337 'entity' => 'PaymentToken',
338 'bao' => 'CRM_Financial_DAO_PaymentToken',
339 'localizable' => 0,
340 'add' => '4.6',
341 ],
342 ];
343 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
344 }
345 return Civi::$statics[__CLASS__]['fields'];
346 }
347
348 /**
349 * Return a mapping from field-name to the corresponding key (as used in fields()).
350 *
351 * @return array
352 * Array(string $name => string $uniqueName).
353 */
354 public static function &fieldKeys() {
355 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
356 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
357 }
358 return Civi::$statics[__CLASS__]['fieldKeys'];
359 }
360
361 /**
362 * Returns the names of this table
363 *
364 * @return string
365 */
366 public static function getTableName() {
367 return self::$_tableName;
368 }
369
370 /**
371 * Returns if this table needs to be logged
372 *
373 * @return bool
374 */
375 public function getLog() {
376 return self::$_log;
377 }
378
379 /**
380 * Returns the list of fields that can be imported
381 *
382 * @param bool $prefix
383 *
384 * @return array
385 */
386 public static function &import($prefix = FALSE) {
387 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'payment_token', $prefix, []);
388 return $r;
389 }
390
391 /**
392 * Returns the list of fields that can be exported
393 *
394 * @param bool $prefix
395 *
396 * @return array
397 */
398 public static function &export($prefix = FALSE) {
399 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'payment_token', $prefix, []);
400 return $r;
401 }
402
403 /**
404 * Returns the list of indices
405 *
406 * @param bool $localize
407 *
408 * @return array
409 */
410 public static function indices($localize = TRUE) {
411 $indices = [];
412 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
413 }
414
415 }