API/DAO Metadata - Retain versioning metadata for possible usage in runtime+tooling
[civicrm-core.git] / CRM / Contribute / DAO / PremiumsProduct.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contribute/PremiumsProduct.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:a250114a018b2fd5e9d259f00d18a5c3)
10 */
11
12 /**
13 * Database access object for the PremiumsProduct entity.
14 */
15 class CRM_Contribute_DAO_PremiumsProduct extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_premiums_product';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 public static $_log = TRUE;
30
31 /**
32 * Contribution ID
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * Foreign key to premiums settings record.
40 *
41 * @var int
42 */
43 public $premiums_id;
44
45 /**
46 * Foreign key to each product object.
47 *
48 * @var int
49 */
50 public $product_id;
51
52 /**
53 * @var int
54 */
55 public $weight;
56
57 /**
58 * FK to Financial Type.
59 *
60 * @var int
61 */
62 public $financial_type_id;
63
64 /**
65 * Class constructor.
66 */
67 public function __construct() {
68 $this->__table = 'civicrm_premiums_product';
69 parent::__construct();
70 }
71
72 /**
73 * Returns localized title of this entity.
74 */
75 public static function getEntityTitle() {
76 return ts('Premiums Products');
77 }
78
79 /**
80 * Returns foreign keys and entity references.
81 *
82 * @return array
83 * [CRM_Core_Reference_Interface]
84 */
85 public static function getReferenceColumns() {
86 if (!isset(Civi::$statics[__CLASS__]['links'])) {
87 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
88 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'premiums_id', 'civicrm_premiums', 'id');
89 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'product_id', 'civicrm_product', 'id');
90 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
91 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
92 }
93 return Civi::$statics[__CLASS__]['links'];
94 }
95
96 /**
97 * Returns all the column names of this table
98 *
99 * @return array
100 */
101 public static function &fields() {
102 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
103 Civi::$statics[__CLASS__]['fields'] = [
104 'id' => [
105 'name' => 'id',
106 'type' => CRM_Utils_Type::T_INT,
107 'title' => ts('Premium Product ID'),
108 'description' => ts('Contribution ID'),
109 'required' => TRUE,
110 'where' => 'civicrm_premiums_product.id',
111 'table_name' => 'civicrm_premiums_product',
112 'entity' => 'PremiumsProduct',
113 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
114 'localizable' => 0,
115 'add' => '1.4',
116 ],
117 'premiums_id' => [
118 'name' => 'premiums_id',
119 'type' => CRM_Utils_Type::T_INT,
120 'title' => ts('Premium'),
121 'description' => ts('Foreign key to premiums settings record.'),
122 'required' => TRUE,
123 'where' => 'civicrm_premiums_product.premiums_id',
124 'table_name' => 'civicrm_premiums_product',
125 'entity' => 'PremiumsProduct',
126 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
127 'localizable' => 0,
128 'FKClassName' => 'CRM_Contribute_DAO_Premium',
129 'add' => '1.4',
130 ],
131 'product_id' => [
132 'name' => 'product_id',
133 'type' => CRM_Utils_Type::T_INT,
134 'title' => ts('Product'),
135 'description' => ts('Foreign key to each product object.'),
136 'required' => TRUE,
137 'where' => 'civicrm_premiums_product.product_id',
138 'table_name' => 'civicrm_premiums_product',
139 'entity' => 'PremiumsProduct',
140 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
141 'localizable' => 0,
142 'FKClassName' => 'CRM_Contribute_DAO_Product',
143 'add' => '1.4',
144 ],
145 'weight' => [
146 'name' => 'weight',
147 'type' => CRM_Utils_Type::T_INT,
148 'title' => ts('Order'),
149 'required' => TRUE,
150 'where' => 'civicrm_premiums_product.weight',
151 'table_name' => 'civicrm_premiums_product',
152 'entity' => 'PremiumsProduct',
153 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
154 'localizable' => 0,
155 'add' => '2.0',
156 ],
157 'financial_type_id' => [
158 'name' => 'financial_type_id',
159 'type' => CRM_Utils_Type::T_INT,
160 'title' => ts('Financial Type'),
161 'description' => ts('FK to Financial Type.'),
162 'where' => 'civicrm_premiums_product.financial_type_id',
163 'default' => 'NULL',
164 'table_name' => 'civicrm_premiums_product',
165 'entity' => 'PremiumsProduct',
166 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
167 'localizable' => 0,
168 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
169 'pseudoconstant' => [
170 'table' => 'civicrm_financial_type',
171 'keyColumn' => 'id',
172 'labelColumn' => 'name',
173 ],
174 'add' => '4.3',
175 ],
176 ];
177 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
178 }
179 return Civi::$statics[__CLASS__]['fields'];
180 }
181
182 /**
183 * Return a mapping from field-name to the corresponding key (as used in fields()).
184 *
185 * @return array
186 * Array(string $name => string $uniqueName).
187 */
188 public static function &fieldKeys() {
189 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
190 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
191 }
192 return Civi::$statics[__CLASS__]['fieldKeys'];
193 }
194
195 /**
196 * Returns the names of this table
197 *
198 * @return string
199 */
200 public static function getTableName() {
201 return self::$_tableName;
202 }
203
204 /**
205 * Returns if this table needs to be logged
206 *
207 * @return bool
208 */
209 public function getLog() {
210 return self::$_log;
211 }
212
213 /**
214 * Returns the list of fields that can be imported
215 *
216 * @param bool $prefix
217 *
218 * @return array
219 */
220 public static function &import($prefix = FALSE) {
221 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'premiums_product', $prefix, []);
222 return $r;
223 }
224
225 /**
226 * Returns the list of fields that can be exported
227 *
228 * @param bool $prefix
229 *
230 * @return array
231 */
232 public static function &export($prefix = FALSE) {
233 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'premiums_product', $prefix, []);
234 return $r;
235 }
236
237 /**
238 * Returns the list of indices
239 *
240 * @param bool $localize
241 *
242 * @return array
243 */
244 public static function indices($localize = TRUE) {
245 $indices = [];
246 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
247 }
248
249 }