Merge pull request #13170 from elisseck/dev/core/485
[civicrm-core.git] / CRM / Core / DAO / Cache.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
6b83d5bd 5 * @copyright CiviCRM LLC (c) 2004-2019
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Core/Cache.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
e380ee3b 9 * (GenCodeChecksum:0683b150dd60e1ec9b53c00957137a27)
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 {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_cache';
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 */
c3fc2621
CW
29 static $_log = FALSE;
30
e501603b 31 /**
e501603b
TO
32 * @var int unsigned
33 */
34 public $id;
c3fc2621 35
e501603b
TO
36 /**
37 * group name for cache element, useful in cleaning cache elements
38 *
39 * @var string
40 */
41 public $group_name;
c3fc2621 42
e501603b
TO
43 /**
44 * Unique path name for cache element
45 *
46 * @var string
47 */
48 public $path;
c3fc2621 49
e501603b
TO
50 /**
51 * data associated with this path
52 *
53 * @var longtext
54 */
55 public $data;
c3fc2621 56
e501603b
TO
57 /**
58 * Component that this menu item belongs to
59 *
60 * @var int unsigned
61 */
62 public $component_id;
c3fc2621 63
e501603b
TO
64 /**
65 * When was the cache item created
66 *
6c2b97b7 67 * @var timestamp
e501603b
TO
68 */
69 public $created_date;
c3fc2621 70
e501603b
TO
71 /**
72 * When should the cache item expire
73 *
6c2b97b7 74 * @var timestamp
e501603b
TO
75 */
76 public $expired_date;
c3fc2621 77
e501603b 78 /**
f41f0342 79 * Class constructor.
e501603b 80 */
c3fc2621 81 public function __construct() {
e501603b
TO
82 $this->__table = 'civicrm_cache';
83 parent::__construct();
84 }
c3fc2621 85
e501603b 86 /**
f41f0342 87 * Returns foreign keys and entity references.
e501603b
TO
88 *
89 * @return array
90 * [CRM_Core_Reference_Interface]
91 */
c3fc2621 92 public static function getReferenceColumns() {
346aaaba
TO
93 if (!isset(Civi::$statics[__CLASS__]['links'])) {
94 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
c3fc2621 95 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'component_id', 'civicrm_component', 'id');
346aaaba 96 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 97 }
346aaaba 98 return Civi::$statics[__CLASS__]['links'];
e501603b 99 }
c3fc2621 100
e501603b
TO
101 /**
102 * Returns all the column names of this table
103 *
104 * @return array
105 */
c3fc2621 106 public static function &fields() {
346aaaba 107 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
108 Civi::$statics[__CLASS__]['fields'] = [
109 'id' => [
e501603b
TO
110 'name' => 'id',
111 'type' => CRM_Utils_Type::T_INT,
c3fc2621 112 'required' => TRUE,
522a26c9 113 'table_name' => 'civicrm_cache',
114 'entity' => 'Cache',
115 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 116 'localizable' => 0,
c3fc2621
CW
117 ],
118 'group_name' => [
e501603b
TO
119 'name' => 'group_name',
120 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 121 'title' => ts('Group Name'),
215b423e 122 'description' => ts('group name for cache element, useful in cleaning cache elements'),
c3fc2621 123 'required' => TRUE,
e501603b
TO
124 'maxlength' => 32,
125 'size' => CRM_Utils_Type::MEDIUM,
522a26c9 126 'table_name' => 'civicrm_cache',
127 'entity' => 'Cache',
128 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 129 'localizable' => 0,
c3fc2621
CW
130 ],
131 'path' => [
e501603b
TO
132 'name' => 'path',
133 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 134 'title' => ts('Path'),
215b423e 135 'description' => ts('Unique path name for cache element'),
e501603b
TO
136 'maxlength' => 255,
137 'size' => CRM_Utils_Type::HUGE,
522a26c9 138 'table_name' => 'civicrm_cache',
139 'entity' => 'Cache',
140 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 141 'localizable' => 0,
c3fc2621
CW
142 ],
143 'data' => [
e501603b
TO
144 'name' => 'data',
145 'type' => CRM_Utils_Type::T_LONGTEXT,
c3fc2621 146 'title' => ts('Data'),
215b423e 147 'description' => ts('data associated with this path'),
522a26c9 148 'table_name' => 'civicrm_cache',
149 'entity' => 'Cache',
150 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 151 'localizable' => 0,
c3fc2621
CW
152 ],
153 'component_id' => [
e501603b
TO
154 'name' => 'component_id',
155 'type' => CRM_Utils_Type::T_INT,
215b423e 156 'description' => ts('Component that this menu item belongs to'),
522a26c9 157 'table_name' => 'civicrm_cache',
158 'entity' => 'Cache',
159 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 160 'localizable' => 0,
e501603b 161 'FKClassName' => 'CRM_Core_DAO_Component',
c3fc2621 162 'html' => [
e501603b 163 'type' => 'Select',
c3fc2621
CW
164 ],
165 'pseudoconstant' => [
e501603b
TO
166 'table' => 'civicrm_component',
167 'keyColumn' => 'id',
168 'labelColumn' => 'name',
c3fc2621
CW
169 ]
170 ],
171 'created_date' => [
e501603b 172 'name' => 'created_date',
6c2b97b7 173 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 174 'title' => ts('Created Date'),
215b423e 175 'description' => ts('When was the cache item created'),
6c2b97b7 176 'default' => 'CURRENT_TIMESTAMP',
522a26c9 177 'table_name' => 'civicrm_cache',
178 'entity' => 'Cache',
179 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 180 'localizable' => 0,
c3fc2621
CW
181 ],
182 'expired_date' => [
e501603b 183 'name' => 'expired_date',
6c2b97b7 184 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 185 'title' => ts('Expired Date'),
215b423e 186 'description' => ts('When should the cache item expire'),
c3fc2621 187 'required' => FALSE,
6c2b97b7 188 'default' => 'NULL',
522a26c9 189 'table_name' => 'civicrm_cache',
190 'entity' => 'Cache',
191 'bao' => 'CRM_Core_BAO_Cache',
6a7e5e5d 192 'localizable' => 0,
c3fc2621
CW
193 ],
194 ];
346aaaba 195 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 196 }
346aaaba 197 return Civi::$statics[__CLASS__]['fields'];
e501603b 198 }
c3fc2621 199
e501603b 200 /**
bd8e0b14 201 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
202 *
203 * @return array
bd8e0b14 204 * Array(string $name => string $uniqueName).
e501603b 205 */
c3fc2621 206 public static function &fieldKeys() {
bd8e0b14
TO
207 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
208 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 209 }
bd8e0b14 210 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 211 }
c3fc2621 212
e501603b
TO
213 /**
214 * Returns the names of this table
215 *
216 * @return string
217 */
c3fc2621 218 public static function getTableName() {
e501603b
TO
219 return self::$_tableName;
220 }
c3fc2621 221
e501603b
TO
222 /**
223 * Returns if this table needs to be logged
224 *
c3fc2621 225 * @return bool
e501603b 226 */
c3fc2621 227 public function getLog() {
e501603b
TO
228 return self::$_log;
229 }
c3fc2621 230
e501603b
TO
231 /**
232 * Returns the list of fields that can be imported
233 *
234 * @param bool $prefix
235 *
236 * @return array
237 */
c3fc2621
CW
238 public static function &import($prefix = FALSE) {
239 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'cache', $prefix, []);
60808919 240 return $r;
e501603b 241 }
c3fc2621 242
e501603b
TO
243 /**
244 * Returns the list of fields that can be exported
245 *
246 * @param bool $prefix
247 *
248 * @return array
249 */
c3fc2621
CW
250 public static function &export($prefix = FALSE) {
251 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'cache', $prefix, []);
60808919 252 return $r;
e501603b 253 }
c3fc2621 254
e7a6b91a
AS
255 /**
256 * Returns the list of indices
c3fc2621
CW
257 *
258 * @param bool $localize
259 *
260 * @return array
e7a6b91a
AS
261 */
262 public static function indices($localize = TRUE) {
c3fc2621
CW
263 $indices = [
264 'UI_group_path_date' => [
e7a6b91a 265 'name' => 'UI_group_path_date',
c3fc2621 266 'field' => [
e7a6b91a
AS
267 0 => 'group_name',
268 1 => 'path',
269 2 => 'created_date',
c3fc2621
CW
270 ],
271 'localizable' => FALSE,
272 'unique' => TRUE,
e7a6b91a 273 'sig' => 'civicrm_cache::1::group_name::path::created_date',
c3fc2621
CW
274 ],
275 ];
e7a6b91a
AS
276 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
277 }
c3fc2621 278
e501603b 279}