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