Merge pull request #18653 from eileenmcnaughton/token
[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
7b66c3b5 9 * (GenCodeChecksum:bafe6ce2f7fd94b2581bfc4dad813130)
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,
a9d0587b 134 'add' => '2.1',
c3fc2621
CW
135 ],
136 'group_name' => [
e501603b
TO
137 'name' => 'group_name',
138 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 139 'title' => ts('Group Name'),
215b423e 140 'description' => ts('group name for cache element, useful in cleaning cache elements'),
c3fc2621 141 'required' => TRUE,
e501603b
TO
142 'maxlength' => 32,
143 'size' => CRM_Utils_Type::MEDIUM,
a36434b9 144 'where' => 'civicrm_cache.group_name',
522a26c9 145 'table_name' => 'civicrm_cache',
146 'entity' => 'Cache',
147 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 148 'localizable' => 0,
a9d0587b 149 'add' => '2.1',
c3fc2621
CW
150 ],
151 'path' => [
e501603b
TO
152 'name' => 'path',
153 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 154 'title' => ts('Path'),
215b423e 155 'description' => ts('Unique path name for cache element'),
e501603b
TO
156 'maxlength' => 255,
157 'size' => CRM_Utils_Type::HUGE,
a36434b9 158 'where' => 'civicrm_cache.path',
522a26c9 159 'table_name' => 'civicrm_cache',
160 'entity' => 'Cache',
161 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 162 'localizable' => 0,
a9d0587b 163 'add' => '2.1',
c3fc2621
CW
164 ],
165 'data' => [
e501603b
TO
166 'name' => 'data',
167 'type' => CRM_Utils_Type::T_LONGTEXT,
c3fc2621 168 'title' => ts('Data'),
215b423e 169 'description' => ts('data associated with this path'),
a36434b9 170 'where' => 'civicrm_cache.data',
522a26c9 171 'table_name' => 'civicrm_cache',
172 'entity' => 'Cache',
173 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 174 'localizable' => 0,
a9d0587b 175 'add' => '2.1',
c3fc2621
CW
176 ],
177 'component_id' => [
e501603b
TO
178 'name' => 'component_id',
179 'type' => CRM_Utils_Type::T_INT,
6692f42b 180 'title' => ts('Component ID'),
215b423e 181 'description' => ts('Component that this menu item belongs to'),
a36434b9 182 'where' => 'civicrm_cache.component_id',
522a26c9 183 'table_name' => 'civicrm_cache',
184 'entity' => 'Cache',
185 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 186 'localizable' => 0,
e501603b 187 'FKClassName' => 'CRM_Core_DAO_Component',
c3fc2621 188 'html' => [
e501603b 189 'type' => 'Select',
c3fc2621
CW
190 ],
191 'pseudoconstant' => [
e501603b
TO
192 'table' => 'civicrm_component',
193 'keyColumn' => 'id',
194 'labelColumn' => 'name',
e6ca0a57 195 ],
a9d0587b 196 'add' => '2.1',
c3fc2621
CW
197 ],
198 'created_date' => [
e501603b 199 'name' => 'created_date',
6c2b97b7 200 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 201 'title' => ts('Created Date'),
215b423e 202 'description' => ts('When was the cache item created'),
a36434b9 203 'where' => 'civicrm_cache.created_date',
6c2b97b7 204 'default' => 'CURRENT_TIMESTAMP',
522a26c9 205 'table_name' => 'civicrm_cache',
206 'entity' => 'Cache',
207 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 208 'localizable' => 0,
a9d0587b 209 'add' => '2.1',
c3fc2621
CW
210 ],
211 'expired_date' => [
e501603b 212 'name' => 'expired_date',
6c2b97b7 213 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 214 'title' => ts('Expired Date'),
215b423e 215 'description' => ts('When should the cache item expire'),
c3fc2621 216 'required' => FALSE,
a36434b9 217 'where' => 'civicrm_cache.expired_date',
6c2b97b7 218 'default' => 'NULL',
522a26c9 219 'table_name' => 'civicrm_cache',
220 'entity' => 'Cache',
221 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 222 'localizable' => 0,
a9d0587b 223 'add' => '2.1',
c3fc2621
CW
224 ],
225 ];
346aaaba 226 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 227 }
346aaaba 228 return Civi::$statics[__CLASS__]['fields'];
e501603b 229 }
c3fc2621 230
e501603b 231 /**
bd8e0b14 232 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
233 *
234 * @return array
bd8e0b14 235 * Array(string $name => string $uniqueName).
e501603b 236 */
c3fc2621 237 public static function &fieldKeys() {
bd8e0b14
TO
238 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
239 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 240 }
bd8e0b14 241 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 242 }
c3fc2621 243
e501603b
TO
244 /**
245 * Returns the names of this table
246 *
247 * @return string
248 */
c3fc2621 249 public static function getTableName() {
e501603b
TO
250 return self::$_tableName;
251 }
c3fc2621 252
e501603b
TO
253 /**
254 * Returns if this table needs to be logged
255 *
c3fc2621 256 * @return bool
e501603b 257 */
c3fc2621 258 public function getLog() {
e501603b
TO
259 return self::$_log;
260 }
c3fc2621 261
e501603b
TO
262 /**
263 * Returns the list of fields that can be imported
264 *
265 * @param bool $prefix
266 *
267 * @return array
268 */
c3fc2621
CW
269 public static function &import($prefix = FALSE) {
270 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'cache', $prefix, []);
60808919 271 return $r;
e501603b 272 }
c3fc2621 273
e501603b
TO
274 /**
275 * Returns the list of fields that can be exported
276 *
277 * @param bool $prefix
278 *
279 * @return array
280 */
c3fc2621
CW
281 public static function &export($prefix = FALSE) {
282 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'cache', $prefix, []);
60808919 283 return $r;
e501603b 284 }
c3fc2621 285
e7a6b91a
AS
286 /**
287 * Returns the list of indices
c3fc2621
CW
288 *
289 * @param bool $localize
290 *
291 * @return array
e7a6b91a
AS
292 */
293 public static function indices($localize = TRUE) {
c3fc2621
CW
294 $indices = [
295 'UI_group_path_date' => [
e7a6b91a 296 'name' => 'UI_group_path_date',
c3fc2621 297 'field' => [
e7a6b91a
AS
298 0 => 'group_name',
299 1 => 'path',
300 2 => 'created_date',
c3fc2621
CW
301 ],
302 'localizable' => FALSE,
303 'unique' => TRUE,
e7a6b91a 304 'sig' => 'civicrm_cache::1::group_name::path::created_date',
c3fc2621
CW
305 ],
306 ];
e7a6b91a
AS
307 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
308 }
c3fc2621 309
e501603b 310}