Completed
Push — master ( df8ec4...96358d )
by Nazar
04:25
created

cache   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
lcom 0
cbo 3
dl 0
loc 39
rs 10
c 1
b 0
f 1

1 Method

Rating   Name   Duplication   Size   Complexity  
C admin_cache_delete() 0 34 7
1
<?php
2
/**
3
 * @package    CleverStyle CMS
4
 * @subpackage System module
5
 * @category   modules
6
 * @author     Nazar Mokrynskyi <[email protected]>
7
 * @copyright  Copyright (c) 2015, Nazar Mokrynskyi
8
 * @license    MIT License, see license.txt
9
 */
10
namespace cs\modules\System\api\Controller\admin;
11
use
12
	cs\Cache as System_cache,
13
	cs\Page,
14
	cs\Route;
15
trait cache {
16
	/**
17
	 * Clear system or static cache
18
	 */
19
	static function admin_cache_delete () {
20
		$Cache = System_cache::instance();
21
		$Page  = Page::instance();
22
		$rc    = Route::instance()->route;
23
		if (isset($rc[2])) {
24
			switch ($rc[2]) {
25
				case 'clean_cache':
26
					time_limit_pause();
27
					if ($_POST['partial_path']) {
28
						$result = $Cache->del($_POST['partial_path']);
29
					} else {
30
						$result = $Cache->clean();
31
						clean_classes_cache();
32
					}
33
					time_limit_pause(false);
34
					if ($result) {
35
						$Cache->disable();
36
						$Page->content(1);
37
					} else {
38
						$Page->content(0);
39
					}
40
					break;
41
				case 'clean_pcache':
42
					if (clean_pcache()) {
43
						$Page->content(1);
44
					} else {
45
						$Page->content(0);
46
					}
47
					break;
48
			}
49
		} else {
50
			$Page->content(0);
51
		}
52
	}
53
}
54