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