Merge remote-tracking branch 'origin/5.44' into master-544-fwd
[civicrm-core.git] / CRM / Core / DAO / Cache.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/Cache.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
2562d09a 9 * (GenCodeChecksum:da6b1275fea0ffb19d09613211f7628e)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Cache entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_Cache extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '2.1';
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_cache';
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 33 /**
6692f42b
PN
34 * Unique table ID
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * group name for cache element, useful in cleaning cache elements
42 *
43 * @var string
44 */
45 public $group_name;
c3fc2621 46
e501603b
TO
47 /**
48 * Unique path name for cache element
49 *
50 * @var string
51 */
52 public $path;
c3fc2621 53
e501603b
TO
54 /**
55 * data associated with this path
56 *
57 * @var longtext
58 */
59 public $data;
c3fc2621 60
e501603b
TO
61 /**
62 * Component that this menu item belongs to
63 *
e6ca0a57 64 * @var int
e501603b
TO
65 */
66 public $component_id;
c3fc2621 67
e501603b
TO
68 /**
69 * When was the cache item created
70 *
6c2b97b7 71 * @var timestamp
e501603b
TO
72 */
73 public $created_date;
c3fc2621 74
e501603b
TO
75 /**
76 * When should the cache item expire
77 *
6c2b97b7 78 * @var timestamp
e501603b
TO
79 */
80 public $expired_date;
c3fc2621 81
e501603b 82 /**
f41f0342 83 * Class constructor.
e501603b 84 */
c3fc2621 85 public function __construct() {
e501603b
TO
86 $this->__table = 'civicrm_cache';
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('Caches') : ts('Cache');
449c4e6b
CW
98 }
99
e501603b 100 /**
f41f0342 101 * Returns foreign keys and entity references.
e501603b
TO
102 *
103 * @return array
104 * [CRM_Core_Reference_Interface]
105 */
c3fc2621 106 public static function getReferenceColumns() {
346aaaba 107 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 108 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 109 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'component_id', 'civicrm_component', 'id');
346aaaba 110 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 111 }
346aaaba 112 return Civi::$statics[__CLASS__]['links'];
e501603b 113 }
c3fc2621 114
e501603b
TO
115 /**
116 * Returns all the column names of this table
117 *
118 * @return array
119 */
c3fc2621 120 public static function &fields() {
346aaaba 121 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
122 Civi::$statics[__CLASS__]['fields'] = [
123 'id' => [
e501603b
TO
124 'name' => 'id',
125 'type' => CRM_Utils_Type::T_INT,
6692f42b
PN
126 'title' => ts('Cache ID'),
127 'description' => ts('Unique table ID'),
c3fc2621 128 'required' => TRUE,
a36434b9 129 'where' => 'civicrm_cache.id',
522a26c9 130 'table_name' => 'civicrm_cache',
131 'entity' => 'Cache',
132 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 133 'localizable' => 0,
2cbbebe8
A
134 'html' => [
135 'type' => 'Number',
136 ],
1fe423d6 137 'readonly' => TRUE,
a9d0587b 138 'add' => '2.1',
c3fc2621
CW
139 ],
140 'group_name' => [
e501603b
TO
141 'name' => 'group_name',
142 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 143 'title' => ts('Group Name'),
215b423e 144 'description' => ts('group name for cache element, useful in cleaning cache elements'),
c3fc2621 145 'required' => TRUE,
e501603b
TO
146 'maxlength' => 32,
147 'size' => CRM_Utils_Type::MEDIUM,
a36434b9 148 'where' => 'civicrm_cache.group_name',
522a26c9 149 'table_name' => 'civicrm_cache',
150 'entity' => 'Cache',
151 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 152 'localizable' => 0,
a9d0587b 153 'add' => '2.1',
c3fc2621
CW
154 ],
155 'path' => [
e501603b
TO
156 'name' => 'path',
157 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 158 'title' => ts('Path'),
215b423e 159 'description' => ts('Unique path name for cache element'),
e501603b
TO
160 'maxlength' => 255,
161 'size' => CRM_Utils_Type::HUGE,
a36434b9 162 'where' => 'civicrm_cache.path',
522a26c9 163 'table_name' => 'civicrm_cache',
164 'entity' => 'Cache',
165 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 166 'localizable' => 0,
a9d0587b 167 'add' => '2.1',
c3fc2621
CW
168 ],
169 'data' => [
e501603b
TO
170 'name' => 'data',
171 'type' => CRM_Utils_Type::T_LONGTEXT,
c3fc2621 172 'title' => ts('Data'),
215b423e 173 'description' => ts('data associated with this path'),
a36434b9 174 'where' => 'civicrm_cache.data',
522a26c9 175 'table_name' => 'civicrm_cache',
176 'entity' => 'Cache',
177 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 178 'localizable' => 0,
a9d0587b 179 'add' => '2.1',
c3fc2621
CW
180 ],
181 'component_id' => [
e501603b
TO
182 'name' => 'component_id',
183 'type' => CRM_Utils_Type::T_INT,
6692f42b 184 'title' => ts('Component ID'),
215b423e 185 'description' => ts('Component that this menu item belongs to'),
a36434b9 186 'where' => 'civicrm_cache.component_id',
522a26c9 187 'table_name' => 'civicrm_cache',
188 'entity' => 'Cache',
189 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 190 'localizable' => 0,
e501603b 191 'FKClassName' => 'CRM_Core_DAO_Component',
c3fc2621 192 'html' => [
e501603b 193 'type' => 'Select',
2cbbebe8 194 'label' => ts("Component"),
c3fc2621
CW
195 ],
196 'pseudoconstant' => [
e501603b
TO
197 'table' => 'civicrm_component',
198 'keyColumn' => 'id',
199 'labelColumn' => 'name',
e6ca0a57 200 ],
a9d0587b 201 'add' => '2.1',
c3fc2621
CW
202 ],
203 'created_date' => [
e501603b 204 'name' => 'created_date',
6c2b97b7 205 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 206 'title' => ts('Created Date'),
215b423e 207 'description' => ts('When was the cache item created'),
a36434b9 208 'where' => 'civicrm_cache.created_date',
6c2b97b7 209 'default' => 'CURRENT_TIMESTAMP',
522a26c9 210 'table_name' => 'civicrm_cache',
211 'entity' => 'Cache',
212 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 213 'localizable' => 0,
a9d0587b 214 'add' => '2.1',
c3fc2621
CW
215 ],
216 'expired_date' => [
e501603b 217 'name' => 'expired_date',
6c2b97b7 218 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 219 'title' => ts('Expired Date'),
215b423e 220 'description' => ts('When should the cache item expire'),
c3fc2621 221 'required' => FALSE,
a36434b9 222 'where' => 'civicrm_cache.expired_date',
5fb0de1f 223 'default' => NULL,
522a26c9 224 'table_name' => 'civicrm_cache',
225 'entity' => 'Cache',
226 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 227 'localizable' => 0,
a9d0587b 228 'add' => '2.1',
c3fc2621
CW
229 ],
230 ];
346aaaba 231 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 232 }
346aaaba 233 return Civi::$statics[__CLASS__]['fields'];
e501603b 234 }
c3fc2621 235
e501603b 236 /**
bd8e0b14 237 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
238 *
239 * @return array
bd8e0b14 240 * Array(string $name => string $uniqueName).
e501603b 241 */
c3fc2621 242 public static function &fieldKeys() {
bd8e0b14
TO
243 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
244 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 245 }
bd8e0b14 246 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 247 }
c3fc2621 248
e501603b
TO
249 /**
250 * Returns the names of this table
251 *
252 * @return string
253 */
c3fc2621 254 public static function getTableName() {
e501603b
TO
255 return self::$_tableName;
256 }
c3fc2621 257
e501603b
TO
258 /**
259 * Returns if this table needs to be logged
260 *
c3fc2621 261 * @return bool
e501603b 262 */
c3fc2621 263 public function getLog() {
e501603b
TO
264 return self::$_log;
265 }
c3fc2621 266
e501603b
TO
267 /**
268 * Returns the list of fields that can be imported
269 *
270 * @param bool $prefix
271 *
272 * @return array
273 */
c3fc2621
CW
274 public static function &import($prefix = FALSE) {
275 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'cache', $prefix, []);
60808919 276 return $r;
e501603b 277 }
c3fc2621 278
e501603b
TO
279 /**
280 * Returns the list of fields that can be exported
281 *
282 * @param bool $prefix
283 *
284 * @return array
285 */
c3fc2621
CW
286 public static function &export($prefix = FALSE) {
287 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'cache', $prefix, []);
60808919 288 return $r;
e501603b 289 }
c3fc2621 290
e7a6b91a
AS
291 /**
292 * Returns the list of indices
c3fc2621
CW
293 *
294 * @param bool $localize
295 *
296 * @return array
e7a6b91a
AS
297 */
298 public static function indices($localize = TRUE) {
c3fc2621
CW
299 $indices = [
300 'UI_group_path_date' => [
e7a6b91a 301 'name' => 'UI_group_path_date',
c3fc2621 302 'field' => [
e7a6b91a
AS
303 0 => 'group_name',
304 1 => 'path',
305 2 => 'created_date',
c3fc2621
CW
306 ],
307 'localizable' => FALSE,
308 'unique' => TRUE,
e7a6b91a 309 'sig' => 'civicrm_cache::1::group_name::path::created_date',
c3fc2621
CW
310 ],
311 ];
e7a6b91a
AS
312 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
313 }
c3fc2621 314
e501603b 315}