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 * Configurations cache manager.
16 */
17 class ConfigsCacheManager extends CacheManager
18 {
19 public $title = "Configurations";
20 public $description = "Configurations des différents composants du framework.";
21 public $group = 'system';
22
23 public function __construct()
24 {
25 global $core;
26
27 $this->state = $core->config['cache configs'];
28 }
29
30 /**
31 * Clears the cache.
32 */
33 public function clear()
34 {
35 global $core;
36
37 $path = $core->config['repository.cache'] . '/core';
38 $files = glob(\ICanBoogie\DOCUMENT_ROOT . $path . '/config_*');
39
40 foreach ($files as $file)
41 {
42 unlink($file);
43 }
44
45 return count($files);
46 }
47
48 /**
49 * Disables the cache.
50 *
51 * Unsets the `enable_modules_cache` var.
52 */
53 public function disable()
54 {
55 global $core;
56
57 unset($core->vars['enable_configs_cache']);
58
59 return true;
60 }
61
62 /**
63 * Enables the cache.
64 *
65 * Sets the `enable_modules_cache` var.
66 */
67 public function enable()
68 {
69 global $core;
70
71 $core->vars['enable_configs_cache'] = true;
72
73 return true;
74 }
75
76 /**
77 * Return stats about the cache.
78 */
79 public function stat()
80 {
81 global $core;
82
83 $path = $core->config['repository.cache'] . '/core';
84
85 return Module::get_files_stat($path, '#^config_#');
86 }
87 }