DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / Core / DAO / SystemLog.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/Core/SystemLog.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
7b66c3b5 9 * (GenCodeChecksum:3765c5a89ca1e9ff224fbd49e31a4037)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the SystemLog entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.5';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_system_log';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = FALSE;
c3fc2621 32
e501603b
TO
33 /**
34 * Primary key ID
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * Standardized message
42 *
43 * @var string
44 */
45 public $message;
c3fc2621 46
e501603b
TO
47 /**
48 * JSON encoded data
49 *
50 * @var longtext
51 */
52 public $context;
c3fc2621 53
e501603b
TO
54 /**
55 * error level per PSR3
56 *
57 * @var string
58 */
59 public $level;
c3fc2621 60
e501603b
TO
61 /**
62 * Timestamp of when event occurred.
63 *
64 * @var timestamp
65 */
66 public $timestamp;
c3fc2621 67
e501603b
TO
68 /**
69 * Optional Contact ID that created the log. Not an FK as we keep this regardless
70 *
e6ca0a57 71 * @var int
e501603b
TO
72 */
73 public $contact_id;
c3fc2621 74
e501603b
TO
75 /**
76 * Optional Name of logging host
77 *
78 * @var string
79 */
80 public $hostname;
c3fc2621 81
e501603b 82 /**
f41f0342 83 * Class constructor.
e501603b 84 */
c3fc2621 85 public function __construct() {
e501603b
TO
86 $this->__table = 'civicrm_system_log';
87 parent::__construct();
88 }
c3fc2621 89
449c4e6b
CW
90 /**
91 * Returns localized title of this entity.
7b66c3b5
AH
92 *
93 * @param bool $plural
94 * Whether to return the plural version of the title.
449c4e6b 95 */
7b66c3b5
AH
96 public static function getEntityTitle($plural = FALSE) {
97 return $plural ? ts('System Logs') : ts('System Log');
449c4e6b
CW
98 }
99
e501603b
TO
100 /**
101 * Returns all the column names of this table
102 *
103 * @return array
104 */
c3fc2621 105 public static function &fields() {
346aaaba 106 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
107 Civi::$statics[__CLASS__]['fields'] = [
108 'id' => [
e501603b
TO
109 'name' => 'id',
110 'type' => CRM_Utils_Type::T_INT,
c3fc2621 111 'title' => ts('System Log ID'),
215b423e 112 'description' => ts('Primary key ID'),
c3fc2621 113 'required' => TRUE,
a36434b9 114 'where' => 'civicrm_system_log.id',
522a26c9 115 'table_name' => 'civicrm_system_log',
116 'entity' => 'SystemLog',
117 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 118 'localizable' => 0,
a9d0587b 119 'add' => '4.4',
c3fc2621
CW
120 ],
121 'message' => [
e501603b
TO
122 'name' => 'message',
123 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 124 'title' => ts('System Log Message'),
215b423e 125 'description' => ts('Standardized message'),
c3fc2621 126 'required' => TRUE,
e501603b
TO
127 'maxlength' => 128,
128 'size' => CRM_Utils_Type::HUGE,
a36434b9 129 'where' => 'civicrm_system_log.message',
522a26c9 130 'table_name' => 'civicrm_system_log',
131 'entity' => 'SystemLog',
132 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 133 'localizable' => 0,
a9d0587b 134 'add' => '4.5',
c3fc2621
CW
135 ],
136 'context' => [
e501603b
TO
137 'name' => 'context',
138 'type' => CRM_Utils_Type::T_LONGTEXT,
c3fc2621 139 'title' => ts('Detailed Log Data'),
215b423e 140 'description' => ts('JSON encoded data'),
a36434b9 141 'where' => 'civicrm_system_log.context',
522a26c9 142 'table_name' => 'civicrm_system_log',
143 'entity' => 'SystemLog',
144 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 145 'localizable' => 0,
a9d0587b 146 'add' => '4.5',
c3fc2621
CW
147 ],
148 'level' => [
e501603b
TO
149 'name' => 'level',
150 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 151 'title' => ts('Detailed Log Data'),
215b423e 152 'description' => ts('error level per PSR3'),
e501603b
TO
153 'maxlength' => 9,
154 'size' => CRM_Utils_Type::TWELVE,
a36434b9 155 'where' => 'civicrm_system_log.level',
e501603b 156 'default' => 'info',
522a26c9 157 'table_name' => 'civicrm_system_log',
158 'entity' => 'SystemLog',
159 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 160 'localizable' => 0,
a9d0587b 161 'add' => '4.5',
c3fc2621
CW
162 ],
163 'timestamp' => [
e501603b
TO
164 'name' => 'timestamp',
165 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 166 'title' => ts('Log Timestamp'),
215b423e 167 'description' => ts('Timestamp of when event occurred.'),
a36434b9 168 'where' => 'civicrm_system_log.timestamp',
e501603b 169 'default' => 'CURRENT_TIMESTAMP',
522a26c9 170 'table_name' => 'civicrm_system_log',
171 'entity' => 'SystemLog',
172 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 173 'localizable' => 0,
a9d0587b 174 'add' => '4.5',
c3fc2621
CW
175 ],
176 'contact_id' => [
e501603b
TO
177 'name' => 'contact_id',
178 'type' => CRM_Utils_Type::T_INT,
c3fc2621 179 'title' => ts('Log Contact ID'),
215b423e 180 'description' => ts('Optional Contact ID that created the log. Not an FK as we keep this regardless'),
a36434b9 181 'where' => 'civicrm_system_log.contact_id',
522a26c9 182 'table_name' => 'civicrm_system_log',
183 'entity' => 'SystemLog',
184 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 185 'localizable' => 0,
a9d0587b 186 'add' => '4.5',
c3fc2621
CW
187 ],
188 'hostname' => [
e501603b
TO
189 'name' => 'hostname',
190 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 191 'title' => ts('Log Host'),
215b423e 192 'description' => ts('Optional Name of logging host'),
e501603b
TO
193 'maxlength' => 128,
194 'size' => CRM_Utils_Type::HUGE,
a36434b9 195 'where' => 'civicrm_system_log.hostname',
522a26c9 196 'table_name' => 'civicrm_system_log',
197 'entity' => 'SystemLog',
198 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 199 'localizable' => 0,
a9d0587b 200 'add' => '4.5',
c3fc2621
CW
201 ],
202 ];
346aaaba 203 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 204 }
346aaaba 205 return Civi::$statics[__CLASS__]['fields'];
e501603b 206 }
c3fc2621 207
e501603b 208 /**
bd8e0b14 209 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
210 *
211 * @return array
bd8e0b14 212 * Array(string $name => string $uniqueName).
e501603b 213 */
c3fc2621 214 public static function &fieldKeys() {
bd8e0b14
TO
215 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
216 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 217 }
bd8e0b14 218 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 219 }
c3fc2621 220
e501603b
TO
221 /**
222 * Returns the names of this table
223 *
224 * @return string
225 */
c3fc2621 226 public static function getTableName() {
e501603b
TO
227 return self::$_tableName;
228 }
c3fc2621 229
e501603b
TO
230 /**
231 * Returns if this table needs to be logged
232 *
c3fc2621 233 * @return bool
e501603b 234 */
c3fc2621 235 public function getLog() {
e501603b
TO
236 return self::$_log;
237 }
c3fc2621 238
e501603b
TO
239 /**
240 * Returns the list of fields that can be imported
241 *
242 * @param bool $prefix
243 *
244 * @return array
245 */
c3fc2621
CW
246 public static function &import($prefix = FALSE) {
247 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'system_log', $prefix, []);
60808919 248 return $r;
e501603b 249 }
c3fc2621 250
e501603b
TO
251 /**
252 * Returns the list of fields that can be exported
253 *
254 * @param bool $prefix
255 *
256 * @return array
257 */
c3fc2621
CW
258 public static function &export($prefix = FALSE) {
259 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'system_log', $prefix, []);
60808919 260 return $r;
e501603b 261 }
c3fc2621 262
e7a6b91a
AS
263 /**
264 * Returns the list of indices
c3fc2621
CW
265 *
266 * @param bool $localize
267 *
268 * @return array
e7a6b91a
AS
269 */
270 public static function indices($localize = TRUE) {
c3fc2621 271 $indices = [];
e7a6b91a
AS
272 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
273 }
c3fc2621 274
e501603b 275}