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