Elgg  Version master
ViewCacher.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Cache;
3 
4 use Elgg\Includer;
7 use Elgg\Config;
8 
12 class ViewCacher {
13 
20  public function __construct(protected ViewsService $views, protected Config $config) {
21  }
22 
28  public function registerCoreViews() {
29  if ($this->views->isViewLocationsLoadedFromCache()) {
30  return;
31  }
32 
33  // Core view files in /views
34  $this->views->registerViewsFromPath(Paths::elgg());
35 
36  // Core view definitions in /engine/views.php
37  $file = Paths::elgg() . 'engine/views.php';
38  if (!is_file($file)) {
39  return;
40  }
41 
42  $spec = Includer::includeFile($file);
43  if (is_array($spec)) {
44  // check for uploaded fontawesome font
45  if ($this->config->font_awesome_zip) {
46  $spec['default']['font-awesome/'] = elgg_get_data_path() . 'fontawesome/webfont/';
47  }
48 
49  $this->views->mergeViewsSpec($spec);
50  }
51  }
52 }
static includeFile($file)
Include a file with as little context as possible.
Definition: Includer.php:18
Handles caching of views in the system cache.
Definition: ViewCacher.php:12
static elgg()
Get the Elgg codebase path with "/".
Definition: Paths.php:44
registerCoreViews()
Discover the core views if the system cache did not load.
Definition: ViewCacher.php:28
$config
Advanced site settings, debugging section.
Definition: debugging.php:6
__construct(protected ViewsService $views, protected Config $config)
Constructor.
Definition: ViewCacher.php:20
Views service.
elgg_get_data_path()
Get the data directory path for this installation, ending with slash.
$views
Definition: item.php:17