1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
namespace Xervice\Twig; |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
use Xervice\Config\XerviceConfig; |
9
|
|
|
use Xervice\Core\Config\AbstractConfig; |
10
|
|
|
use Xervice\Core\CoreConfig; |
11
|
|
|
|
12
|
|
|
class TwigConfig extends AbstractConfig |
13
|
|
|
{ |
14
|
|
|
public const DEBUG = 'twig.debug'; |
15
|
|
|
|
16
|
|
|
public const CHARSET = 'twig.charset'; |
17
|
|
|
|
18
|
|
|
public const BASE_TEMPLATE_CLASS = 'twig.base.template.class'; |
19
|
|
|
|
20
|
|
|
public const STRICT_VARIABLES = 'twig.strict.variables'; |
21
|
|
|
|
22
|
|
|
public const AUTOESCAPE = 'twig.autoescape'; |
23
|
|
|
|
24
|
|
|
public const CACHE = 'twig.cache'; |
25
|
|
|
|
26
|
|
|
public const CACHE_PATH = 'twig.cache.path'; |
27
|
|
|
|
28
|
|
|
public const AUTO_RELOAD = 'twig.auto.reload'; |
29
|
|
|
|
30
|
|
|
public const OPTIMIZATIONS = 'twig.optimizations'; |
31
|
|
|
|
32
|
|
|
public const MODULE_PATHS = 'twig.module.paths'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return array |
36
|
|
|
*/ |
37
|
2 |
|
public function getModulePaths(): array |
38
|
|
|
{ |
39
|
2 |
|
return $this->get( |
40
|
2 |
|
self::MODULE_PATHS, |
41
|
|
|
[ |
42
|
2 |
|
sprintf( |
43
|
2 |
|
'%s/src/%s', |
44
|
2 |
|
$this->get(XerviceConfig::APPLICATION_PATH), |
45
|
2 |
|
$this->get(CoreConfig::PROJECT_LAYER_NAMESPACE) |
46
|
|
|
), |
47
|
2 |
|
sprintf( |
48
|
2 |
|
'%s/src/%s', |
49
|
2 |
|
$this->get(XerviceConfig::APPLICATION_PATH), |
50
|
2 |
|
'Xervice' |
51
|
|
|
), |
52
|
2 |
|
sprintf( |
53
|
2 |
|
'%s/vendor/xervice/*/src/Xervice', |
54
|
2 |
|
$this->get(XerviceConfig::APPLICATION_PATH) |
55
|
|
|
) |
56
|
|
|
] |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return bool |
62
|
|
|
*/ |
63
|
2 |
|
public function isDebug(): bool |
64
|
|
|
{ |
65
|
2 |
|
return $this->get(self::DEBUG, false); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
2 |
|
public function getCharset(): string |
72
|
|
|
{ |
73
|
2 |
|
return $this->get(self::CHARSET, 'UTF-8'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
2 |
|
public function getBaseTemplateClass(): string |
80
|
|
|
{ |
81
|
2 |
|
return $this->get(self::BASE_TEMPLATE_CLASS, 'Twig_Template'); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return bool |
86
|
|
|
*/ |
87
|
2 |
|
public function isStrictVariables(): bool |
88
|
|
|
{ |
89
|
2 |
|
return $this->get(self::STRICT_VARIABLES, false); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
2 |
|
public function getAutoescape(): string |
96
|
|
|
{ |
97
|
2 |
|
return $this->get(self::AUTOESCAPE, 'html'); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return bool |
102
|
|
|
*/ |
103
|
2 |
|
public function isCache(): bool |
104
|
|
|
{ |
105
|
2 |
|
return $this->get(self::CACHE, false); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
public function getCachePath(): string |
112
|
|
|
{ |
113
|
|
|
return $this->get(self::CACHE_PATH); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return bool |
118
|
|
|
*/ |
119
|
2 |
|
public function isAutoReload(): bool |
120
|
|
|
{ |
121
|
2 |
|
return $this->get(self::AUTO_RELOAD, false); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return int |
126
|
|
|
*/ |
127
|
2 |
|
public function getOptimization(): int |
128
|
|
|
{ |
129
|
2 |
|
return $this->get(self::OPTIMIZATIONS, -1); |
130
|
|
|
} |
131
|
|
|
} |