Merge pull request #20211 from eileenmcnaughton/reorg
[civicrm-core.git] / CRM / Financial / DAO / EntityFinancialAccount.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Financial/EntityFinancialAccount.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:70f25c56047d21ecc405e8b7a60ef68d)
10 */
11
12 /**
13 * Database access object for the EntityFinancialAccount entity.
14 */
15 class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.3';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_entity_financial_account';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = TRUE;
33
34 /**
35 * ID
36 *
37 * @var int
38 */
39 public $id;
40
41 /**
42 * Links to an entity_table like civicrm_financial_type
43 *
44 * @var string
45 */
46 public $entity_table;
47
48 /**
49 * Links to an id in the entity_table, such as vid in civicrm_financial_type
50 *
51 * @var int
52 */
53 public $entity_id;
54
55 /**
56 * FK to a new civicrm_option_value (account_relationship)
57 *
58 * @var int
59 */
60 public $account_relationship;
61
62 /**
63 * FK to the financial_account_id
64 *
65 * @var int
66 */
67 public $financial_account_id;
68
69 /**
70 * Class constructor.
71 */
72 public function __construct() {
73 $this->__table = 'civicrm_entity_financial_account';
74 parent::__construct();
75 }
76
77 /**
78 * Returns localized title of this entity.
79 *
80 * @param bool $plural
81 * Whether to return the plural version of the title.
82 */
83 public static function getEntityTitle($plural = FALSE) {
84 return $plural ? ts('Entity Financial Accounts') : ts('Entity Financial Account');
85 }
86
87 /**
88 * Returns foreign keys and entity references.
89 *
90 * @return array
91 * [CRM_Core_Reference_Interface]
92 */
93 public static function getReferenceColumns() {
94 if (!isset(Civi::$statics[__CLASS__]['links'])) {
95 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
96 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
97 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
98 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
99 }
100 return Civi::$statics[__CLASS__]['links'];
101 }
102
103 /**
104 * Returns all the column names of this table
105 *
106 * @return array
107 */
108 public static function &fields() {
109 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
110 Civi::$statics[__CLASS__]['fields'] = [
111 'id' => [
112 'name' => 'id',
113 'type' => CRM_Utils_Type::T_INT,
114 'title' => ts('Entity Financial Account ID'),
115 'description' => ts('ID'),
116 'required' => TRUE,
117 'where' => 'civicrm_entity_financial_account.id',
118 'table_name' => 'civicrm_entity_financial_account',
119 'entity' => 'EntityFinancialAccount',
120 'bao' => 'CRM_Financial_BAO_EntityFinancialAccount',
121 'localizable' => 0,
122 'html' => [
123 'type' => 'Number',
124 ],
125 'readonly' => TRUE,
126 'add' => '4.3',
127 ],
128 'entity_table' => [
129 'name' => 'entity_table',
130 'type' => CRM_Utils_Type::T_STRING,
131 'title' => ts('Entity Table'),
132 'description' => ts('Links to an entity_table like civicrm_financial_type'),
133 'required' => TRUE,
134 'maxlength' => 64,
135 'size' => CRM_Utils_Type::BIG,
136 'import' => TRUE,
137 'where' => 'civicrm_entity_financial_account.entity_table',
138 'export' => TRUE,
139 'table_name' => 'civicrm_entity_financial_account',
140 'entity' => 'EntityFinancialAccount',
141 'bao' => 'CRM_Financial_BAO_EntityFinancialAccount',
142 'localizable' => 0,
143 'pseudoconstant' => [
144 'callback' => 'CRM_Financial_BAO_EntityFinancialAccount::entityTables',
145 ],
146 'add' => '4.3',
147 ],
148 'entity_id' => [
149 'name' => 'entity_id',
150 'type' => CRM_Utils_Type::T_INT,
151 'title' => ts('Entity ID'),
152 'description' => ts('Links to an id in the entity_table, such as vid in civicrm_financial_type'),
153 'required' => TRUE,
154 'where' => 'civicrm_entity_financial_account.entity_id',
155 'table_name' => 'civicrm_entity_financial_account',
156 'entity' => 'EntityFinancialAccount',
157 'bao' => 'CRM_Financial_BAO_EntityFinancialAccount',
158 'localizable' => 0,
159 'add' => '4.3',
160 ],
161 'account_relationship' => [
162 'name' => 'account_relationship',
163 'type' => CRM_Utils_Type::T_INT,
164 'title' => ts('Account Relationship'),
165 'description' => ts('FK to a new civicrm_option_value (account_relationship)'),
166 'required' => TRUE,
167 'where' => 'civicrm_entity_financial_account.account_relationship',
168 'table_name' => 'civicrm_entity_financial_account',
169 'entity' => 'EntityFinancialAccount',
170 'bao' => 'CRM_Financial_BAO_EntityFinancialAccount',
171 'localizable' => 0,
172 'html' => [
173 'type' => 'Select',
174 ],
175 'pseudoconstant' => [
176 'optionGroupName' => 'account_relationship',
177 'optionEditPath' => 'civicrm/admin/options/account_relationship',
178 ],
179 'add' => '4.3',
180 ],
181 'financial_account_id' => [
182 'name' => 'financial_account_id',
183 'type' => CRM_Utils_Type::T_INT,
184 'title' => ts('Financial Account ID'),
185 'description' => ts('FK to the financial_account_id'),
186 'required' => TRUE,
187 'where' => 'civicrm_entity_financial_account.financial_account_id',
188 'table_name' => 'civicrm_entity_financial_account',
189 'entity' => 'EntityFinancialAccount',
190 'bao' => 'CRM_Financial_BAO_EntityFinancialAccount',
191 'localizable' => 0,
192 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
193 'html' => [
194 'type' => 'Select',
195 'label' => ts("Financial Account"),
196 ],
197 'pseudoconstant' => [
198 'table' => 'civicrm_financial_account',
199 'keyColumn' => 'id',
200 'labelColumn' => 'name',
201 ],
202 'add' => '4.3',
203 ],
204 ];
205 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
206 }
207 return Civi::$statics[__CLASS__]['fields'];
208 }
209
210 /**
211 * Return a mapping from field-name to the corresponding key (as used in fields()).
212 *
213 * @return array
214 * Array(string $name => string $uniqueName).
215 */
216 public static function &fieldKeys() {
217 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
218 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
219 }
220 return Civi::$statics[__CLASS__]['fieldKeys'];
221 }
222
223 /**
224 * Returns the names of this table
225 *
226 * @return string
227 */
228 public static function getTableName() {
229 return self::$_tableName;
230 }
231
232 /**
233 * Returns if this table needs to be logged
234 *
235 * @return bool
236 */
237 public function getLog() {
238 return self::$_log;
239 }
240
241 /**
242 * Returns the list of fields that can be imported
243 *
244 * @param bool $prefix
245 *
246 * @return array
247 */
248 public static function &import($prefix = FALSE) {
249 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'entity_financial_account', $prefix, []);
250 return $r;
251 }
252
253 /**
254 * Returns the list of fields that can be exported
255 *
256 * @param bool $prefix
257 *
258 * @return array
259 */
260 public static function &export($prefix = FALSE) {
261 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'entity_financial_account', $prefix, []);
262 return $r;
263 }
264
265 /**
266 * Returns the list of indices
267 *
268 * @param bool $localize
269 *
270 * @return array
271 */
272 public static function indices($localize = TRUE) {
273 $indices = [
274 'index_entity_id_entity_table_account_relationship' => [
275 'name' => 'index_entity_id_entity_table_account_relationship',
276 'field' => [
277 0 => 'entity_id',
278 1 => 'entity_table',
279 2 => 'account_relationship',
280 ],
281 'localizable' => FALSE,
282 'unique' => TRUE,
283 'sig' => 'civicrm_entity_financial_account::1::entity_id::entity_table::account_relationship',
284 ],
285 ];
286 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
287 }
288
289 }