Test Failed
Push — master ( c2873c...a077d1 )
by Jeroen
01:35
created

engine/classes/Elgg/Cache/ViewCacher.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Elgg\Cache;
3
4
use Elgg\Includer;
5
use Elgg\Project\Paths;
6
use Elgg\ViewsService;
7
use Elgg\Config;
8
9
/**
10
 * Handles caching of views in the system cache
11
 */
12
class ViewCacher {
13
14
	/**
15
	 * @var ViewsService
16
	 */
17
	private $views;
18
19
	/**
20
	 * @var Config
21
	 */
22
	private $config;
23
24
	/**
25
	 * Constructor
26
	 *
27
	 * @param ViewsService $views  Views
28
	 * @param Config       $config Config
29
	 */
30
	public function __construct(ViewsService $views, Config $config) {
31
		$this->views = $views;
32
		$this->config = $config;
33
	}
34
35
	/**
36
	 * Discover the views if the system cache did not load
37
	 *
38
	 * @return void
39
	 */
40
	public function registerCoreViews() {
41 View Code Duplication
		if (!$this->config->system_cache_loaded) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
			// Core view files in /views
43
			$this->views->registerPluginViews(Paths::project());
44
45
			// Core view definitions in /engine/views.php
46
			$file = Paths::elgg() . 'engine/views.php';
47
			if (is_file($file)) {
48
				$spec = Includer::includeFile($file);
49
				if (is_array($spec)) {
50
					$this->views->mergeViewsSpec($spec);
51
				}
52
			}
53
		}
54
	}
55
}
56