DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / Event / Cart / DAO / Cart.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/Event/Cart/Cart.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
7b66c3b5 9 * (GenCodeChecksum:b7a4ad0bbb09a64b8afefd7a1a2d6a9b)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Cart entity.
f41f0342 14 */
e501603b 15class CRM_Event_Cart_DAO_Cart extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '';
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_event_carts';
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 * Cart Id
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * FK to civicrm_contact who created this cart
42 *
e6ca0a57 43 * @var int
e501603b
TO
44 */
45 public $user_id;
c3fc2621 46
e501603b 47 /**
e6ca0a57 48 * @var bool
e501603b
TO
49 */
50 public $completed;
c3fc2621 51
e501603b 52 /**
f41f0342 53 * Class constructor.
e501603b 54 */
c3fc2621 55 public function __construct() {
e501603b
TO
56 $this->__table = 'civicrm_event_carts';
57 parent::__construct();
58 }
c3fc2621 59
449c4e6b
CW
60 /**
61 * Returns localized title of this entity.
7b66c3b5
AH
62 *
63 * @param bool $plural
64 * Whether to return the plural version of the title.
449c4e6b 65 */
7b66c3b5
AH
66 public static function getEntityTitle($plural = FALSE) {
67 return $plural ? ts('Carts') : ts('Cart');
449c4e6b
CW
68 }
69
e501603b 70 /**
f41f0342 71 * Returns foreign keys and entity references.
e501603b
TO
72 *
73 * @return array
74 * [CRM_Core_Reference_Interface]
75 */
c3fc2621 76 public static function getReferenceColumns() {
346aaaba 77 if (!isset(Civi::$statics[__CLASS__]['links'])) {
a36434b9 78 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 79 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'user_id', 'civicrm_contact', 'id');
346aaaba 80 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 81 }
346aaaba 82 return Civi::$statics[__CLASS__]['links'];
e501603b 83 }
c3fc2621 84
e501603b
TO
85 /**
86 * Returns all the column names of this table
87 *
88 * @return array
89 */
c3fc2621 90 public static function &fields() {
346aaaba 91 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
92 Civi::$statics[__CLASS__]['fields'] = [
93 'cart_id' => [
e501603b
TO
94 'name' => 'id',
95 'type' => CRM_Utils_Type::T_INT,
c3fc2621 96 'title' => ts('Cart ID'),
215b423e 97 'description' => ts('Cart Id'),
c3fc2621 98 'required' => TRUE,
a36434b9 99 'where' => 'civicrm_event_carts.id',
522a26c9 100 'table_name' => 'civicrm_event_carts',
101 'entity' => 'Cart',
102 'bao' => 'CRM_Event_Cart_BAO_Cart',
6a7e5e5d 103 'localizable' => 0,
a9d0587b 104 'add' => '4.1',
c3fc2621
CW
105 ],
106 'user_id' => [
e501603b
TO
107 'name' => 'user_id',
108 'type' => CRM_Utils_Type::T_INT,
c3fc2621 109 'title' => ts('Created By'),
215b423e 110 'description' => ts('FK to civicrm_contact who created this cart'),
a36434b9 111 'where' => 'civicrm_event_carts.user_id',
522a26c9 112 'table_name' => 'civicrm_event_carts',
113 'entity' => 'Cart',
114 'bao' => 'CRM_Event_Cart_BAO_Cart',
6a7e5e5d 115 'localizable' => 0,
e501603b 116 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 117 'add' => '4.1',
c3fc2621
CW
118 ],
119 'completed' => [
e501603b
TO
120 'name' => 'completed',
121 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 122 'title' => ts('Complete?'),
a36434b9 123 'where' => 'civicrm_event_carts.completed',
45a83e42 124 'default' => '0',
522a26c9 125 'table_name' => 'civicrm_event_carts',
126 'entity' => 'Cart',
127 'bao' => 'CRM_Event_Cart_BAO_Cart',
6a7e5e5d 128 'localizable' => 0,
a9d0587b 129 'add' => '4.1',
c3fc2621
CW
130 ],
131 ];
346aaaba 132 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 133 }
346aaaba 134 return Civi::$statics[__CLASS__]['fields'];
e501603b 135 }
c3fc2621 136
e501603b 137 /**
bd8e0b14 138 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
139 *
140 * @return array
bd8e0b14 141 * Array(string $name => string $uniqueName).
e501603b 142 */
c3fc2621 143 public static function &fieldKeys() {
bd8e0b14
TO
144 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
145 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 146 }
bd8e0b14 147 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 148 }
c3fc2621 149
e501603b
TO
150 /**
151 * Returns the names of this table
152 *
153 * @return string
154 */
c3fc2621 155 public static function getTableName() {
e501603b
TO
156 return self::$_tableName;
157 }
c3fc2621 158
e501603b
TO
159 /**
160 * Returns if this table needs to be logged
161 *
c3fc2621 162 * @return bool
e501603b 163 */
c3fc2621 164 public function getLog() {
e501603b
TO
165 return self::$_log;
166 }
c3fc2621 167
e501603b
TO
168 /**
169 * Returns the list of fields that can be imported
170 *
171 * @param bool $prefix
172 *
173 * @return array
174 */
c3fc2621
CW
175 public static function &import($prefix = FALSE) {
176 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'event_carts', $prefix, []);
60808919 177 return $r;
e501603b 178 }
c3fc2621 179
e501603b
TO
180 /**
181 * Returns the list of fields that can be exported
182 *
183 * @param bool $prefix
184 *
185 * @return array
186 */
c3fc2621
CW
187 public static function &export($prefix = FALSE) {
188 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'event_carts', $prefix, []);
60808919 189 return $r;
e501603b 190 }
c3fc2621 191
e7a6b91a
AS
192 /**
193 * Returns the list of indices
c3fc2621
CW
194 *
195 * @param bool $localize
196 *
197 * @return array
e7a6b91a
AS
198 */
199 public static function indices($localize = TRUE) {
c3fc2621 200 $indices = [];
e7a6b91a
AS
201 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
202 }
c3fc2621 203
e501603b 204}