blob: 7f912f6c74155165da5ed4333db68aee8ff5d6b5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<?php
namespace Drupal\Core\Extension;
use Drupal\Component\FileCache\FileCache;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\FileCache\FileCacheInterface;
/**
* Parses extension .info.yml files.
*/
class InfoParser extends InfoParserDynamic {
/**
* The file cache.
*
* @var \Drupal\Component\FileCache\FileCacheInterface
*/
protected FileCacheInterface $fileCache;
/**
* InfoParser constructor.
*
* @param string $app_root
* The root directory of the Drupal installation.
*/
public function __construct(string $app_root) {
parent::__construct($app_root);
if (FileCacheFactory::getPrefix() !== NULL) {
$this->fileCache = FileCacheFactory::get('info_parser');
}
else {
// Just use a static file cache when there is no prefix. This code path is
// triggered when info is parsed prior to
// \Drupal\Core\DrupalKernel::boot() running. This occurs during the very
// early installer and in some test scenarios.
$this->fileCache = new FileCache('info_parser', 'info_parser');
}
}
/**
* {@inheritdoc}
*/
public function parse($filename) {
$data = $this->fileCache->get($filename);
if ($data === NULL) {
$data = parent::parse($filename);
$this->fileCache->set($filename, $data);
}
return $data;
}
}
|