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