1<?php 2namespace Elgg\Cache; 3 4use Elgg\Includer; 5use Elgg\Project\Paths; 6use Elgg\ViewsService; 7use Elgg\Config; 8 9/** 10 * Handles caching of views in the system cache 11 */ 12class 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 core views if the system cache did not load 37 * 38 * @return void 39 */ 40 public function registerCoreViews() { 41 if ($this->config->system_cache_loaded) { 42 return; 43 } 44 45 // Core view files in /views 46 $this->views->registerPluginViews(Paths::elgg()); 47 48 // Core view definitions in /engine/views.php 49 $file = Paths::elgg() . 'engine/views.php'; 50 if (!is_file($file)) { 51 return; 52 } 53 54 $spec = Includer::includeFile($file); 55 if (is_array($spec)) { 56 $this->views->mergeViewsSpec($spec); 57 } 58 } 59} 60