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