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