|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
namespace Xervice\Twig; |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
use Xervice\Config\Business\XerviceConfig; |
|
9
|
|
|
use Xervice\Core\Business\Model\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/*', |
|
44
|
2 |
|
$this->get(XerviceConfig::APPLICATION_PATH) |
|
45
|
|
|
), |
|
46
|
2 |
|
sprintf( |
|
47
|
2 |
|
'%s/vendor/xervice/*/src/Xervice', |
|
48
|
2 |
|
$this->get(XerviceConfig::APPLICATION_PATH) |
|
49
|
|
|
) |
|
50
|
|
|
] |
|
51
|
|
|
); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return bool |
|
56
|
|
|
*/ |
|
57
|
2 |
|
public function isDebug(): bool |
|
58
|
|
|
{ |
|
59
|
2 |
|
return $this->get(self::DEBUG, false); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
2 |
|
public function getCharset(): string |
|
66
|
|
|
{ |
|
67
|
2 |
|
return $this->get(self::CHARSET, 'UTF-8'); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @return string |
|
72
|
|
|
*/ |
|
73
|
2 |
|
public function getBaseTemplateClass(): string |
|
74
|
|
|
{ |
|
75
|
2 |
|
return $this->get(self::BASE_TEMPLATE_CLASS, 'Twig_Template'); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return bool |
|
80
|
|
|
*/ |
|
81
|
2 |
|
public function isStrictVariables(): bool |
|
82
|
|
|
{ |
|
83
|
2 |
|
return $this->get(self::STRICT_VARIABLES, false); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @return string |
|
88
|
|
|
*/ |
|
89
|
2 |
|
public function getAutoescape(): string |
|
90
|
|
|
{ |
|
91
|
2 |
|
return $this->get(self::AUTOESCAPE, 'html'); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @return bool |
|
96
|
|
|
*/ |
|
97
|
2 |
|
public function isCache(): bool |
|
98
|
|
|
{ |
|
99
|
2 |
|
return $this->get(self::CACHE, false); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return string |
|
104
|
|
|
*/ |
|
105
|
|
|
public function getCachePath(): string |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->get(self::CACHE_PATH); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @return bool |
|
112
|
|
|
*/ |
|
113
|
2 |
|
public function isAutoReload(): bool |
|
114
|
|
|
{ |
|
115
|
2 |
|
return $this->get(self::AUTO_RELOAD, false); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @return int |
|
120
|
|
|
*/ |
|
121
|
2 |
|
public function getOptimization(): int |
|
122
|
|
|
{ |
|
123
|
2 |
|
return $this->get(self::OPTIMIZATIONS, -1); |
|
124
|
|
|
} |
|
125
|
|
|
} |