DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / Price / DAO / PriceSetEntity.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Price/PriceSetEntity.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:0284d1a184dd635d93dd170e94451e86)
10 */
11
12 /**
13 * Database access object for the PriceSetEntity entity.
14 */
15 class CRM_Price_DAO_PriceSetEntity extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.8';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_price_set_entity';
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 = TRUE;
32
33 /**
34 * Price Set Entity
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Table which uses this price set
42 *
43 * @var string
44 */
45 public $entity_table;
46
47 /**
48 * Item in table
49 *
50 * @var int
51 */
52 public $entity_id;
53
54 /**
55 * price set being used
56 *
57 * @var int
58 */
59 public $price_set_id;
60
61 /**
62 * Class constructor.
63 */
64 public function __construct() {
65 $this->__table = 'civicrm_price_set_entity';
66 parent::__construct();
67 }
68
69 /**
70 * Returns localized title of this entity.
71 *
72 * @param bool $plural
73 * Whether to return the plural version of the title.
74 */
75 public static function getEntityTitle($plural = FALSE) {
76 return $plural ? ts('Price Set Entities') : ts('Price Set Entity');
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(), 'price_set_id', 'civicrm_price_set', 'id');
89 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
90 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
91 }
92 return Civi::$statics[__CLASS__]['links'];
93 }
94
95 /**
96 * Returns all the column names of this table
97 *
98 * @return array
99 */
100 public static function &fields() {
101 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
102 Civi::$statics[__CLASS__]['fields'] = [
103 'id' => [
104 'name' => 'id',
105 'type' => CRM_Utils_Type::T_INT,
106 'title' => ts('Price Set Entity ID'),
107 'description' => ts('Price Set Entity'),
108 'required' => TRUE,
109 'where' => 'civicrm_price_set_entity.id',
110 'table_name' => 'civicrm_price_set_entity',
111 'entity' => 'PriceSetEntity',
112 'bao' => 'CRM_Price_DAO_PriceSetEntity',
113 'localizable' => 0,
114 'add' => '1.8',
115 ],
116 'entity_table' => [
117 'name' => 'entity_table',
118 'type' => CRM_Utils_Type::T_STRING,
119 'title' => ts('Entity Table'),
120 'description' => ts('Table which uses this price set'),
121 'required' => TRUE,
122 'maxlength' => 64,
123 'size' => CRM_Utils_Type::BIG,
124 'where' => 'civicrm_price_set_entity.entity_table',
125 'table_name' => 'civicrm_price_set_entity',
126 'entity' => 'PriceSetEntity',
127 'bao' => 'CRM_Price_DAO_PriceSetEntity',
128 'localizable' => 0,
129 'add' => '1.8',
130 ],
131 'entity_id' => [
132 'name' => 'entity_id',
133 'type' => CRM_Utils_Type::T_INT,
134 'title' => ts('Entity IF'),
135 'description' => ts('Item in table'),
136 'required' => TRUE,
137 'where' => 'civicrm_price_set_entity.entity_id',
138 'table_name' => 'civicrm_price_set_entity',
139 'entity' => 'PriceSetEntity',
140 'bao' => 'CRM_Price_DAO_PriceSetEntity',
141 'localizable' => 0,
142 'add' => '1.8',
143 ],
144 'price_set_id' => [
145 'name' => 'price_set_id',
146 'type' => CRM_Utils_Type::T_INT,
147 'title' => ts('Price Set'),
148 'description' => ts('price set being used'),
149 'required' => TRUE,
150 'where' => 'civicrm_price_set_entity.price_set_id',
151 'table_name' => 'civicrm_price_set_entity',
152 'entity' => 'PriceSetEntity',
153 'bao' => 'CRM_Price_DAO_PriceSetEntity',
154 'localizable' => 0,
155 'FKClassName' => 'CRM_Price_DAO_PriceSet',
156 'pseudoconstant' => [
157 'table' => 'civicrm_price_set',
158 'keyColumn' => 'id',
159 'labelColumn' => 'title',
160 ],
161 'add' => '1.8',
162 ],
163 ];
164 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
165 }
166 return Civi::$statics[__CLASS__]['fields'];
167 }
168
169 /**
170 * Return a mapping from field-name to the corresponding key (as used in fields()).
171 *
172 * @return array
173 * Array(string $name => string $uniqueName).
174 */
175 public static function &fieldKeys() {
176 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
177 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
178 }
179 return Civi::$statics[__CLASS__]['fieldKeys'];
180 }
181
182 /**
183 * Returns the names of this table
184 *
185 * @return string
186 */
187 public static function getTableName() {
188 return self::$_tableName;
189 }
190
191 /**
192 * Returns if this table needs to be logged
193 *
194 * @return bool
195 */
196 public function getLog() {
197 return self::$_log;
198 }
199
200 /**
201 * Returns the list of fields that can be imported
202 *
203 * @param bool $prefix
204 *
205 * @return array
206 */
207 public static function &import($prefix = FALSE) {
208 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'price_set_entity', $prefix, []);
209 return $r;
210 }
211
212 /**
213 * Returns the list of fields that can be exported
214 *
215 * @param bool $prefix
216 *
217 * @return array
218 */
219 public static function &export($prefix = FALSE) {
220 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'price_set_entity', $prefix, []);
221 return $r;
222 }
223
224 /**
225 * Returns the list of indices
226 *
227 * @param bool $localize
228 *
229 * @return array
230 */
231 public static function indices($localize = TRUE) {
232 $indices = [
233 'UI_entity' => [
234 'name' => 'UI_entity',
235 'field' => [
236 0 => 'entity_table',
237 1 => 'entity_id',
238 ],
239 'localizable' => FALSE,
240 'unique' => TRUE,
241 'sig' => 'civicrm_price_set_entity::1::entity_table::entity_id',
242 ],
243 ];
244 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
245 }
246
247 }