API/DAO Metadata - Retain versioning metadata for possible usage in runtime+tooling
[civicrm-core.git] / CRM / Core / DAO / Log.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Log.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:a102ecbdf345a1df748ea11fdd997b9e)
10 */
11
12 /**
13 * Database access object for the Log entity.
14 */
15 class CRM_Core_DAO_Log extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_log';
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 * Log ID
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * Name of table where item being referenced is stored.
40 *
41 * @var string
42 */
43 public $entity_table;
44
45 /**
46 * Foreign key to the referenced item.
47 *
48 * @var int
49 */
50 public $entity_id;
51
52 /**
53 * Updates does to this object if any.
54 *
55 * @var text
56 */
57 public $data;
58
59 /**
60 * FK to Contact ID of person under whose credentials this data modification was made.
61 *
62 * @var int
63 */
64 public $modified_id;
65
66 /**
67 * When was the referenced entity created or modified or deleted.
68 *
69 * @var datetime
70 */
71 public $modified_date;
72
73 /**
74 * Class constructor.
75 */
76 public function __construct() {
77 $this->__table = 'civicrm_log';
78 parent::__construct();
79 }
80
81 /**
82 * Returns localized title of this entity.
83 */
84 public static function getEntityTitle() {
85 return ts('Logs');
86 }
87
88 /**
89 * Returns foreign keys and entity references.
90 *
91 * @return array
92 * [CRM_Core_Reference_Interface]
93 */
94 public static function getReferenceColumns() {
95 if (!isset(Civi::$statics[__CLASS__]['links'])) {
96 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
97 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id');
98 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
99 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
100 }
101 return Civi::$statics[__CLASS__]['links'];
102 }
103
104 /**
105 * Returns all the column names of this table
106 *
107 * @return array
108 */
109 public static function &fields() {
110 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
111 Civi::$statics[__CLASS__]['fields'] = [
112 'id' => [
113 'name' => 'id',
114 'type' => CRM_Utils_Type::T_INT,
115 'title' => ts('Log ID'),
116 'description' => ts('Log ID'),
117 'required' => TRUE,
118 'where' => 'civicrm_log.id',
119 'table_name' => 'civicrm_log',
120 'entity' => 'Log',
121 'bao' => 'CRM_Core_BAO_Log',
122 'localizable' => 0,
123 'add' => '1.5',
124 ],
125 'entity_table' => [
126 'name' => 'entity_table',
127 'type' => CRM_Utils_Type::T_STRING,
128 'title' => ts('Entity Table'),
129 'description' => ts('Name of table where item being referenced is stored.'),
130 'required' => TRUE,
131 'maxlength' => 64,
132 'size' => CRM_Utils_Type::BIG,
133 'where' => 'civicrm_log.entity_table',
134 'table_name' => 'civicrm_log',
135 'entity' => 'Log',
136 'bao' => 'CRM_Core_BAO_Log',
137 'localizable' => 0,
138 'add' => '1.5',
139 ],
140 'entity_id' => [
141 'name' => 'entity_id',
142 'type' => CRM_Utils_Type::T_INT,
143 'title' => ts('Entity ID '),
144 'description' => ts('Foreign key to the referenced item.'),
145 'required' => TRUE,
146 'where' => 'civicrm_log.entity_id',
147 'table_name' => 'civicrm_log',
148 'entity' => 'Log',
149 'bao' => 'CRM_Core_BAO_Log',
150 'localizable' => 0,
151 'add' => '1.5',
152 ],
153 'data' => [
154 'name' => 'data',
155 'type' => CRM_Utils_Type::T_TEXT,
156 'title' => ts('Data'),
157 'description' => ts('Updates does to this object if any.'),
158 'where' => 'civicrm_log.data',
159 'table_name' => 'civicrm_log',
160 'entity' => 'Log',
161 'bao' => 'CRM_Core_BAO_Log',
162 'localizable' => 0,
163 'add' => '1.5',
164 ],
165 'modified_id' => [
166 'name' => 'modified_id',
167 'type' => CRM_Utils_Type::T_INT,
168 'title' => ts('Modified By'),
169 'description' => ts('FK to Contact ID of person under whose credentials this data modification was made.'),
170 'where' => 'civicrm_log.modified_id',
171 'table_name' => 'civicrm_log',
172 'entity' => 'Log',
173 'bao' => 'CRM_Core_BAO_Log',
174 'localizable' => 0,
175 'FKClassName' => 'CRM_Contact_DAO_Contact',
176 'add' => '1.5',
177 ],
178 'modified_date' => [
179 'name' => 'modified_date',
180 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
181 'title' => ts('Modified Date'),
182 'description' => ts('When was the referenced entity created or modified or deleted.'),
183 'where' => 'civicrm_log.modified_date',
184 'table_name' => 'civicrm_log',
185 'entity' => 'Log',
186 'bao' => 'CRM_Core_BAO_Log',
187 'localizable' => 0,
188 'add' => '1.5',
189 ],
190 ];
191 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
192 }
193 return Civi::$statics[__CLASS__]['fields'];
194 }
195
196 /**
197 * Return a mapping from field-name to the corresponding key (as used in fields()).
198 *
199 * @return array
200 * Array(string $name => string $uniqueName).
201 */
202 public static function &fieldKeys() {
203 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
204 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
205 }
206 return Civi::$statics[__CLASS__]['fieldKeys'];
207 }
208
209 /**
210 * Returns the names of this table
211 *
212 * @return string
213 */
214 public static function getTableName() {
215 return self::$_tableName;
216 }
217
218 /**
219 * Returns if this table needs to be logged
220 *
221 * @return bool
222 */
223 public function getLog() {
224 return self::$_log;
225 }
226
227 /**
228 * Returns the list of fields that can be imported
229 *
230 * @param bool $prefix
231 *
232 * @return array
233 */
234 public static function &import($prefix = FALSE) {
235 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'log', $prefix, []);
236 return $r;
237 }
238
239 /**
240 * Returns the list of fields that can be exported
241 *
242 * @param bool $prefix
243 *
244 * @return array
245 */
246 public static function &export($prefix = FALSE) {
247 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'log', $prefix, []);
248 return $r;
249 }
250
251 /**
252 * Returns the list of indices
253 *
254 * @param bool $localize
255 *
256 * @return array
257 */
258 public static function indices($localize = TRUE) {
259 $indices = [
260 'index_entity' => [
261 'name' => 'index_entity',
262 'field' => [
263 0 => 'entity_table',
264 1 => 'entity_id',
265 ],
266 'localizable' => FALSE,
267 'sig' => 'civicrm_log::0::entity_table::entity_id',
268 ],
269 ];
270 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
271 }
272
273 }