Merge pull request #17321 from artfulrobot/artfulrobot-identify-request-key
[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:c0e05c7f98e0801599d18ab12b1937a7)
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 ],
116 'premiums_id' => [
117 'name' => 'premiums_id',
118 'type' => CRM_Utils_Type::T_INT,
119 'title' => ts('Premium'),
120 'description' => ts('Foreign key to premiums settings record.'),
121 'required' => TRUE,
122 'where' => 'civicrm_premiums_product.premiums_id',
123 'table_name' => 'civicrm_premiums_product',
124 'entity' => 'PremiumsProduct',
125 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
126 'localizable' => 0,
127 'FKClassName' => 'CRM_Contribute_DAO_Premium',
128 ],
129 'product_id' => [
130 'name' => 'product_id',
131 'type' => CRM_Utils_Type::T_INT,
132 'title' => ts('Product'),
133 'description' => ts('Foreign key to each product object.'),
134 'required' => TRUE,
135 'where' => 'civicrm_premiums_product.product_id',
136 'table_name' => 'civicrm_premiums_product',
137 'entity' => 'PremiumsProduct',
138 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
139 'localizable' => 0,
140 'FKClassName' => 'CRM_Contribute_DAO_Product',
141 ],
142 'weight' => [
143 'name' => 'weight',
144 'type' => CRM_Utils_Type::T_INT,
145 'title' => ts('Order'),
146 'required' => TRUE,
147 'where' => 'civicrm_premiums_product.weight',
148 'table_name' => 'civicrm_premiums_product',
149 'entity' => 'PremiumsProduct',
150 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
151 'localizable' => 0,
152 ],
153 'financial_type_id' => [
154 'name' => 'financial_type_id',
155 'type' => CRM_Utils_Type::T_INT,
156 'title' => ts('Financial Type'),
157 'description' => ts('FK to Financial Type.'),
158 'where' => 'civicrm_premiums_product.financial_type_id',
159 'default' => 'NULL',
160 'table_name' => 'civicrm_premiums_product',
161 'entity' => 'PremiumsProduct',
162 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
163 'localizable' => 0,
164 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
165 'pseudoconstant' => [
166 'table' => 'civicrm_financial_type',
167 'keyColumn' => 'id',
168 'labelColumn' => 'name',
169 ],
170 ],
171 ];
172 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
173 }
174 return Civi::$statics[__CLASS__]['fields'];
175 }
176
177 /**
178 * Return a mapping from field-name to the corresponding key (as used in fields()).
179 *
180 * @return array
181 * Array(string $name => string $uniqueName).
182 */
183 public static function &fieldKeys() {
184 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
185 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
186 }
187 return Civi::$statics[__CLASS__]['fieldKeys'];
188 }
189
190 /**
191 * Returns the names of this table
192 *
193 * @return string
194 */
195 public static function getTableName() {
196 return self::$_tableName;
197 }
198
199 /**
200 * Returns if this table needs to be logged
201 *
202 * @return bool
203 */
204 public function getLog() {
205 return self::$_log;
206 }
207
208 /**
209 * Returns the list of fields that can be imported
210 *
211 * @param bool $prefix
212 *
213 * @return array
214 */
215 public static function &import($prefix = FALSE) {
216 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'premiums_product', $prefix, []);
217 return $r;
218 }
219
220 /**
221 * Returns the list of fields that can be exported
222 *
223 * @param bool $prefix
224 *
225 * @return array
226 */
227 public static function &export($prefix = FALSE) {
228 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'premiums_product', $prefix, []);
229 return $r;
230 }
231
232 /**
233 * Returns the list of indices
234 *
235 * @param bool $localize
236 *
237 * @return array
238 */
239 public static function indices($localize = TRUE) {
240 $indices = [];
241 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
242 }
243
244 }