1 <?php
2
3 /*
4 * This file is part of the Icybee package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Icybee\Modules\Views;
13
14 use ICanBoogie\HTTP\Request;
15 use ICanBoogie\Operation;
16
17 class CacheManager implements \Icybee\Modules\Cache\CacheManagerInterface
18 {
19 public $title = "Vues";
20 public $description = "Index des vues des modules.";
21 public $group = 'system';
22 public $state = false;
23 public $config_preview;
24
25 public function __construct()
26 {
27 global $core;
28
29 $this->state = $core->config['cache views'];
30 }
31
32 /**
33 * Clears the cache.
34 */
35 public function clear()
36 {
37 global $core;
38
39 unset($core->vars['cached_views']);
40
41 return true;
42 }
43
44 /**
45 * Disables caching.
46 *
47 * Unsets the `enable_modules_cache` var.
48 */
49 public function disable()
50 {
51 global $core;
52
53 unset($core->vars['enable_views_cache']);
54
55 return true;
56 }
57
58 /**
59 * Enables caching.
60 *
61 * Sets the `enable_modules_cache` var.
62 */
63 public function enable()
64 {
65 global $core;
66
67 $core->vars['enable_views_cache'] = true;
68
69 return true;
70 }
71
72 /**
73 * Return stats about the cache.
74 */
75 public function stat()
76 {
77 return \Icybee\Modules\Cache\Module::get_vars_stat('#^cached_views$#');
78 }
79
80 /**
81 * Revokes the cache.
82 */
83 static public function revoke()
84 {
85 Request::from(Operation::encode('cache/icybee.views/clear'))->post();
86 }
87 }