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\Cache;
13
14 /**
15 * Modules cache manager.
16 */
17 class ModulesCacheManager extends CacheManager
18 {
19 const REGEX = '/^cached_modules_/';
20
21 public $title = "Modules";
22 public $description = "Index des modules disponibles pour le framework.";
23 public $group = 'system';
24
25 public function __construct()
26 {
27 global $core;
28
29 $this->state = $core->config['cache modules'];
30 }
31
32 /**
33 * Clears the cache.
34 */
35 public function clear()
36 {
37 global $core;
38
39 $iterator = $core->vars->matching(self::REGEX);
40 $iterator->delete();
41
42 return true;
43 }
44
45 /**
46 * Disables the cache.
47 *
48 * Unsets the `enable_modules_cache` var.
49 */
50 public function disable()
51 {
52 global $core;
53
54 unset($core->vars['enable_modules_cache']);
55
56 return true;
57 }
58
59 /**
60 * Enables the cache.
61 *
62 * Sets the `enable_modules_cache` var.
63 */
64 public function enable()
65 {
66 global $core;
67
68 $core->vars['enable_modules_cache'] = true;
69
70 return true;
71 }
72
73 /**
74 * Return stats about the cache.
75 */
76 public function stat()
77 {
78 return Module::get_vars_stat(self::REGEX);
79 }
80 }