Add "labelField" metadata to entities
[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:e7fe0d109914d345588895ccf1838406)
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_DAO_EntityFinancialAccount',
121 'localizable' => 0,
122 'add' => '4.3',
123 ],
124 'entity_table' => [
125 'name' => 'entity_table',
126 'type' => CRM_Utils_Type::T_STRING,
127 'title' => ts('Entity Table'),
128 'description' => ts('Links to an entity_table like civicrm_financial_type'),
129 'required' => TRUE,
130 'maxlength' => 64,
131 'size' => CRM_Utils_Type::BIG,
132 'import' => TRUE,
133 'where' => 'civicrm_entity_financial_account.entity_table',
134 'export' => TRUE,
135 'table_name' => 'civicrm_entity_financial_account',
136 'entity' => 'EntityFinancialAccount',
137 'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
138 'localizable' => 0,
139 'add' => '4.3',
140 ],
141 'entity_id' => [
142 'name' => 'entity_id',
143 'type' => CRM_Utils_Type::T_INT,
144 'title' => ts('Entity ID'),
145 'description' => ts('Links to an id in the entity_table, such as vid in civicrm_financial_type'),
146 'required' => TRUE,
147 'where' => 'civicrm_entity_financial_account.entity_id',
148 'table_name' => 'civicrm_entity_financial_account',
149 'entity' => 'EntityFinancialAccount',
150 'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
151 'localizable' => 0,
152 'add' => '4.3',
153 ],
154 'account_relationship' => [
155 'name' => 'account_relationship',
156 'type' => CRM_Utils_Type::T_INT,
157 'title' => ts('Account Relationship'),
158 'description' => ts('FK to a new civicrm_option_value (account_relationship)'),
159 'required' => TRUE,
160 'where' => 'civicrm_entity_financial_account.account_relationship',
161 'table_name' => 'civicrm_entity_financial_account',
162 'entity' => 'EntityFinancialAccount',
163 'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
164 'localizable' => 0,
165 'html' => [
166 'type' => 'Select',
167 ],
168 'pseudoconstant' => [
169 'optionGroupName' => 'account_relationship',
170 'optionEditPath' => 'civicrm/admin/options/account_relationship',
171 ],
172 'add' => '4.3',
173 ],
174 'financial_account_id' => [
175 'name' => 'financial_account_id',
176 'type' => CRM_Utils_Type::T_INT,
177 'title' => ts('Financial Account'),
178 'description' => ts('FK to the financial_account_id'),
179 'required' => TRUE,
180 'where' => 'civicrm_entity_financial_account.financial_account_id',
181 'table_name' => 'civicrm_entity_financial_account',
182 'entity' => 'EntityFinancialAccount',
183 'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
184 'localizable' => 0,
185 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
186 'html' => [
187 'type' => 'Select',
188 ],
189 'pseudoconstant' => [
190 'table' => 'civicrm_financial_account',
191 'keyColumn' => 'id',
192 'labelColumn' => 'name',
193 ],
194 'add' => '4.3',
195 ],
196 ];
197 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
198 }
199 return Civi::$statics[__CLASS__]['fields'];
200 }
201
202 /**
203 * Return a mapping from field-name to the corresponding key (as used in fields()).
204 *
205 * @return array
206 * Array(string $name => string $uniqueName).
207 */
208 public static function &fieldKeys() {
209 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
210 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
211 }
212 return Civi::$statics[__CLASS__]['fieldKeys'];
213 }
214
215 /**
216 * Returns the names of this table
217 *
218 * @return string
219 */
220 public static function getTableName() {
221 return self::$_tableName;
222 }
223
224 /**
225 * Returns if this table needs to be logged
226 *
227 * @return bool
228 */
229 public function getLog() {
230 return self::$_log;
231 }
232
233 /**
234 * Returns the list of fields that can be imported
235 *
236 * @param bool $prefix
237 *
238 * @return array
239 */
240 public static function &import($prefix = FALSE) {
241 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'entity_financial_account', $prefix, []);
242 return $r;
243 }
244
245 /**
246 * Returns the list of fields that can be exported
247 *
248 * @param bool $prefix
249 *
250 * @return array
251 */
252 public static function &export($prefix = FALSE) {
253 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'entity_financial_account', $prefix, []);
254 return $r;
255 }
256
257 /**
258 * Returns the list of indices
259 *
260 * @param bool $localize
261 *
262 * @return array
263 */
264 public static function indices($localize = TRUE) {
265 $indices = [
266 'index_entity_id_entity_table_account_relationship' => [
267 'name' => 'index_entity_id_entity_table_account_relationship',
268 'field' => [
269 0 => 'entity_id',
270 1 => 'entity_table',
271 2 => 'account_relationship',
272 ],
273 'localizable' => FALSE,
274 'unique' => TRUE,
275 'sig' => 'civicrm_entity_financial_account::1::entity_id::entity_table::account_relationship',
276 ],
277 ];
278 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
279 }
280
281 }