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