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