@@ -119,25 +119,25 @@ public static function config($name = null, $settings = array()) {
119
119
}
120
120
121
121
$ current = array ();
122
- if (isset (self ::$ _config [$ name ])) {
123
- $ current = self ::$ _config [$ name ];
122
+ if (isset (static ::$ _config [$ name ])) {
123
+ $ current = static ::$ _config [$ name ];
124
124
}
125
125
126
126
if (!empty ($ settings )) {
127
- self ::$ _config [$ name ] = array_merge ($ current , $ settings );
127
+ static ::$ _config [$ name ] = array_merge ($ current , $ settings );
128
128
}
129
129
130
- if (empty (self ::$ _config [$ name ]['engine ' ])) {
130
+ if (empty (static ::$ _config [$ name ]['engine ' ])) {
131
131
return false ;
132
132
}
133
133
134
- $ engine = self ::$ _config [$ name ]['engine ' ];
134
+ $ engine = static ::$ _config [$ name ]['engine ' ];
135
135
136
- if (!isset (self ::$ _engines [$ name ])) {
137
- self ::_buildEngine ($ name );
138
- $ settings = self ::$ _config [$ name ] = self ::settings ($ name );
139
- } elseif ($ settings = self ::set (self ::$ _config [$ name ], null , $ name )) {
140
- self ::$ _config [$ name ] = $ settings ;
136
+ if (!isset (static ::$ _engines [$ name ])) {
137
+ static ::_buildEngine ($ name );
138
+ $ settings = static ::$ _config [$ name ] = static ::settings ($ name );
139
+ } elseif ($ settings = static ::set (static ::$ _config [$ name ], null , $ name )) {
140
+ static ::$ _config [$ name ] = $ settings ;
141
141
}
142
142
return compact ('engine ' , 'settings ' );
143
143
}
@@ -150,7 +150,7 @@ public static function config($name = null, $settings = array()) {
150
150
* @throws CacheException
151
151
*/
152
152
protected static function _buildEngine ($ name ) {
153
- $ config = self ::$ _config [$ name ];
153
+ $ config = static ::$ _config [$ name ];
154
154
155
155
$ cacheClass = App::classname ($ config ['engine ' ], 'Cache/Engine ' , 'Engine ' );
156
156
if (!$ cacheClass ) {
@@ -159,10 +159,10 @@ protected static function _buildEngine($name) {
159
159
if (!is_subclass_of ($ cacheClass , 'Cake\Cache\CacheEngine ' )) {
160
160
throw new Error \CacheException (__d ('cake_dev ' , 'Cache engines must use Cake\Cache\CacheEngine as a base class. ' ));
161
161
}
162
- self ::$ _engines [$ name ] = new $ cacheClass ();
163
- if (self ::$ _engines [$ name ]->init ($ config )) {
164
- if (self ::$ _engines [$ name ]->settings ['probability ' ] && time () % self ::$ _engines [$ name ]->settings ['probability ' ] === 0 ) {
165
- self ::$ _engines [$ name ]->gc ();
162
+ static ::$ _engines [$ name ] = new $ cacheClass ();
163
+ if (static ::$ _engines [$ name ]->init ($ config )) {
164
+ if (static ::$ _engines [$ name ]->settings ['probability ' ] && time () % static ::$ _engines [$ name ]->settings ['probability ' ] === 0 ) {
165
+ static ::$ _engines [$ name ]->gc ();
166
166
}
167
167
return true ;
168
168
}
@@ -175,7 +175,7 @@ protected static function _buildEngine($name) {
175
175
* @return array Array of configured Cache config names.
176
176
*/
177
177
public static function configured () {
178
- return array_keys (self ::$ _config );
178
+ return array_keys (static ::$ _config );
179
179
}
180
180
181
181
/**
@@ -187,10 +187,10 @@ public static function configured() {
187
187
* @return boolean success of the removal, returns false when the config does not exist.
188
188
*/
189
189
public static function drop ($ name ) {
190
- if (!isset (self ::$ _config [$ name ])) {
190
+ if (!isset (static ::$ _config [$ name ])) {
191
191
return false ;
192
192
}
193
- unset(self ::$ _config [$ name ], self ::$ _engines [$ name ]);
193
+ unset(static ::$ _config [$ name ], static ::$ _engines [$ name ]);
194
194
return true ;
195
195
}
196
196
@@ -221,29 +221,29 @@ public static function set($settings = array(), $value = null, $config = 'defaul
221
221
if (is_array ($ settings ) && $ value !== null ) {
222
222
$ config = $ value ;
223
223
}
224
- if (!isset (self ::$ _config [$ config ]) || !isset (self ::$ _engines [$ config ])) {
224
+ if (!isset (static ::$ _config [$ config ]) || !isset (static ::$ _engines [$ config ])) {
225
225
return false ;
226
226
}
227
227
if (!empty ($ settings )) {
228
- self ::$ _reset = true ;
228
+ static ::$ _reset = true ;
229
229
}
230
230
231
- if (self ::$ _reset === true ) {
231
+ if (static ::$ _reset === true ) {
232
232
if (empty ($ settings )) {
233
- self ::$ _reset = false ;
234
- $ settings = self ::$ _config [$ config ];
233
+ static ::$ _reset = false ;
234
+ $ settings = static ::$ _config [$ config ];
235
235
} else {
236
236
if (is_string ($ settings ) && $ value !== null ) {
237
237
$ settings = array ($ settings => $ value );
238
238
}
239
- $ settings = array_merge (self ::$ _config [$ config ], $ settings );
239
+ $ settings = array_merge (static ::$ _config [$ config ], $ settings );
240
240
if (isset ($ settings ['duration ' ]) && !is_numeric ($ settings ['duration ' ])) {
241
241
$ settings ['duration ' ] = strtotime ($ settings ['duration ' ]) - time ();
242
242
}
243
243
}
244
- self ::$ _engines [$ config ]->settings = $ settings ;
244
+ static ::$ _engines [$ config ]->settings = $ settings ;
245
245
}
246
- return self ::settings ($ config );
246
+ return static ::settings ($ config );
247
247
}
248
248
249
249
/**
@@ -256,7 +256,7 @@ public static function set($settings = array(), $value = null, $config = 'defaul
256
256
* @return void
257
257
*/
258
258
public static function gc ($ config = 'default ' , $ expires = null ) {
259
- self ::$ _engines [$ config ]->gc ($ expires );
259
+ static ::$ _engines [$ config ]->gc ($ expires );
260
260
}
261
261
262
262
/**
@@ -280,29 +280,29 @@ public static function gc($config = 'default', $expires = null) {
280
280
* @return boolean True if the data was successfully cached, false on failure
281
281
*/
282
282
public static function write ($ key , $ value , $ config = 'default ' ) {
283
- $ settings = self ::settings ($ config );
283
+ $ settings = static ::settings ($ config );
284
284
285
285
if (empty ($ settings )) {
286
286
return false ;
287
287
}
288
- if (!self ::isInitialized ($ config )) {
288
+ if (!static ::isInitialized ($ config )) {
289
289
return false ;
290
290
}
291
- $ key = self ::$ _engines [$ config ]->key ($ key );
291
+ $ key = static ::$ _engines [$ config ]->key ($ key );
292
292
293
293
if (!$ key || is_resource ($ value )) {
294
294
return false ;
295
295
}
296
296
297
- $ success = self ::$ _engines [$ config ]->write ($ settings ['prefix ' ] . $ key , $ value , $ settings ['duration ' ]);
298
- self ::set (null , $ config );
297
+ $ success = static ::$ _engines [$ config ]->write ($ settings ['prefix ' ] . $ key , $ value , $ settings ['duration ' ]);
298
+ static ::set (null , $ config );
299
299
if ($ success === false && $ value !== '' ) {
300
300
trigger_error (
301
301
__d ('cake_dev ' ,
302
302
"%s cache was unable to write '%s' to %s cache " ,
303
303
$ config ,
304
304
$ key ,
305
- self ::$ _engines [$ config ]->settings ['engine ' ]
305
+ static ::$ _engines [$ config ]->settings ['engine ' ]
306
306
),
307
307
E_USER_WARNING
308
308
);
@@ -330,19 +330,19 @@ public static function write($key, $value, $config = 'default') {
330
330
* @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
331
331
*/
332
332
public static function read ($ key , $ config = 'default ' ) {
333
- $ settings = self ::settings ($ config );
333
+ $ settings = static ::settings ($ config );
334
334
335
335
if (empty ($ settings )) {
336
336
return false ;
337
337
}
338
- if (!self ::isInitialized ($ config )) {
338
+ if (!static ::isInitialized ($ config )) {
339
339
return false ;
340
340
}
341
- $ key = self ::$ _engines [$ config ]->key ($ key );
341
+ $ key = static ::$ _engines [$ config ]->key ($ key );
342
342
if (!$ key ) {
343
343
return false ;
344
344
}
345
- return self ::$ _engines [$ config ]->read ($ settings ['prefix ' ] . $ key );
345
+ return static ::$ _engines [$ config ]->read ($ settings ['prefix ' ] . $ key );
346
346
}
347
347
348
348
/**
@@ -355,21 +355,21 @@ public static function read($key, $config = 'default') {
355
355
* or if there was an error fetching it.
356
356
*/
357
357
public static function increment ($ key , $ offset = 1 , $ config = 'default ' ) {
358
- $ settings = self ::settings ($ config );
358
+ $ settings = static ::settings ($ config );
359
359
360
360
if (empty ($ settings )) {
361
361
return false ;
362
362
}
363
- if (!self ::isInitialized ($ config )) {
363
+ if (!static ::isInitialized ($ config )) {
364
364
return false ;
365
365
}
366
- $ key = self ::$ _engines [$ config ]->key ($ key );
366
+ $ key = static ::$ _engines [$ config ]->key ($ key );
367
367
368
368
if (!$ key || !is_integer ($ offset ) || $ offset < 0 ) {
369
369
return false ;
370
370
}
371
- $ success = self ::$ _engines [$ config ]->increment ($ settings ['prefix ' ] . $ key , $ offset );
372
- self ::set (null , $ config );
371
+ $ success = static ::$ _engines [$ config ]->increment ($ settings ['prefix ' ] . $ key , $ offset );
372
+ static ::set (null , $ config );
373
373
return $ success ;
374
374
}
375
375
@@ -383,21 +383,21 @@ public static function increment($key, $offset = 1, $config = 'default') {
383
383
* or if there was an error fetching it
384
384
*/
385
385
public static function decrement ($ key , $ offset = 1 , $ config = 'default ' ) {
386
- $ settings = self ::settings ($ config );
386
+ $ settings = static ::settings ($ config );
387
387
388
388
if (empty ($ settings )) {
389
389
return false ;
390
390
}
391
- if (!self ::isInitialized ($ config )) {
391
+ if (!static ::isInitialized ($ config )) {
392
392
return false ;
393
393
}
394
- $ key = self ::$ _engines [$ config ]->key ($ key );
394
+ $ key = static ::$ _engines [$ config ]->key ($ key );
395
395
396
396
if (!$ key || !is_integer ($ offset ) || $ offset < 0 ) {
397
397
return false ;
398
398
}
399
- $ success = self ::$ _engines [$ config ]->decrement ($ settings ['prefix ' ] . $ key , $ offset );
400
- self ::set (null , $ config );
399
+ $ success = static ::$ _engines [$ config ]->decrement ($ settings ['prefix ' ] . $ key , $ offset );
400
+ static ::set (null , $ config );
401
401
return $ success ;
402
402
}
403
403
@@ -419,21 +419,21 @@ public static function decrement($key, $offset = 1, $config = 'default') {
419
419
* @return boolean True if the value was successfully deleted, false if it didn't exist or couldn't be removed
420
420
*/
421
421
public static function delete ($ key , $ config = 'default ' ) {
422
- $ settings = self ::settings ($ config );
422
+ $ settings = static ::settings ($ config );
423
423
424
424
if (empty ($ settings )) {
425
425
return false ;
426
426
}
427
- if (!self ::isInitialized ($ config )) {
427
+ if (!static ::isInitialized ($ config )) {
428
428
return false ;
429
429
}
430
- $ key = self ::$ _engines [$ config ]->key ($ key );
430
+ $ key = static ::$ _engines [$ config ]->key ($ key );
431
431
if (!$ key ) {
432
432
return false ;
433
433
}
434
434
435
- $ success = self ::$ _engines [$ config ]->delete ($ settings ['prefix ' ] . $ key );
436
- self ::set (null , $ config );
435
+ $ success = static ::$ _engines [$ config ]->delete ($ settings ['prefix ' ] . $ key );
436
+ static ::set (null , $ config );
437
437
return $ success ;
438
438
}
439
439
@@ -445,11 +445,11 @@ public static function delete($key, $config = 'default') {
445
445
* @return boolean True if the cache was successfully cleared, false otherwise
446
446
*/
447
447
public static function clear ($ check = false , $ config = 'default ' ) {
448
- if (!self ::isInitialized ($ config )) {
448
+ if (!static ::isInitialized ($ config )) {
449
449
return false ;
450
450
}
451
- $ success = self ::$ _engines [$ config ]->clear ($ check );
452
- self ::set (null , $ config );
451
+ $ success = static ::$ _engines [$ config ]->clear ($ check );
452
+ static ::set (null , $ config );
453
453
return $ success ;
454
454
}
455
455
@@ -461,11 +461,11 @@ public static function clear($check = false, $config = 'default') {
461
461
* @return boolean True if the cache group was successfully cleared, false otherwise
462
462
*/
463
463
public static function clearGroup ($ group , $ config = 'default ' ) {
464
- if (!self ::isInitialized ($ config )) {
464
+ if (!static ::isInitialized ($ config )) {
465
465
return false ;
466
466
}
467
- $ success = self ::$ _engines [$ config ]->clearGroup ($ group );
468
- self ::set (null , $ config );
467
+ $ success = static ::$ _engines [$ config ]->clearGroup ($ group );
468
+ static ::set (null , $ config );
469
469
return $ success ;
470
470
}
471
471
@@ -479,7 +479,7 @@ public static function isInitialized($config = 'default') {
479
479
if (Configure::read ('Cache.disable ' )) {
480
480
return false ;
481
481
}
482
- return isset (self ::$ _engines [$ config ]);
482
+ return isset (static ::$ _engines [$ config ]);
483
483
}
484
484
485
485
/**
@@ -490,8 +490,8 @@ public static function isInitialized($config = 'default') {
490
490
* @see Cache::config()
491
491
*/
492
492
public static function settings ($ name = 'default ' ) {
493
- if (!empty (self ::$ _engines [$ name ])) {
494
- return self ::$ _engines [$ name ]->settings ();
493
+ if (!empty (static ::$ _engines [$ name ])) {
494
+ return static ::$ _engines [$ name ]->settings ();
495
495
}
496
496
return array ();
497
497
}
0 commit comments