|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
namespace Xervice\Twig; |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
use Xervice\Core\Config\AbstractConfig; |
|
9
|
|
|
|
|
10
|
|
|
class TwigConfig extends AbstractConfig |
|
11
|
|
|
{ |
|
12
|
|
|
public const DEBUG = 'debug'; |
|
13
|
|
|
|
|
14
|
|
|
public const CHARSET = 'charset'; |
|
15
|
|
|
|
|
16
|
|
|
public const BASE_TEMPLATE_CLASS = 'base.template.class'; |
|
17
|
|
|
|
|
18
|
|
|
public const STRICT_VARIABLES = 'strict.variables'; |
|
19
|
|
|
|
|
20
|
|
|
public const AUTOESCAPE = 'autoescape'; |
|
21
|
|
|
|
|
22
|
|
|
public const CACHE = 'cache'; |
|
23
|
|
|
|
|
24
|
|
|
public const CACHE_PATH = 'cache.path'; |
|
25
|
|
|
|
|
26
|
|
|
public const AUTO_RELOAD = 'auto.reload'; |
|
27
|
|
|
|
|
28
|
|
|
public const OPTIMIZATIONS = 'optimizations'; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @return bool |
|
32
|
|
|
*/ |
|
33
|
2 |
|
public function isDebug(): bool |
|
34
|
|
|
{ |
|
35
|
2 |
|
return $this->get(self::DEBUG, false); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @return string |
|
40
|
|
|
*/ |
|
41
|
2 |
|
public function getCharset(): string |
|
42
|
|
|
{ |
|
43
|
2 |
|
return $this->get(self::CHARSET, 'UTF-8'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @return string |
|
48
|
|
|
*/ |
|
49
|
2 |
|
public function getBaseTemplateClass(): string |
|
50
|
|
|
{ |
|
51
|
2 |
|
return $this->get(self::BASE_TEMPLATE_CLASS, 'Twig_Template'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return bool |
|
56
|
|
|
*/ |
|
57
|
2 |
|
public function isStrictVariables(): bool |
|
58
|
|
|
{ |
|
59
|
2 |
|
return $this->get(self::STRICT_VARIABLES, false); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
2 |
|
public function getAutoescape(): string |
|
66
|
|
|
{ |
|
67
|
2 |
|
return $this->get(self::AUTOESCAPE, 'html'); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @return bool |
|
72
|
|
|
*/ |
|
73
|
2 |
|
public function isCache(): bool |
|
74
|
|
|
{ |
|
75
|
2 |
|
return $this->get(self::CACHE, false); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getCachePath(): string |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->get(self::CACHE_PATH); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @return bool |
|
88
|
|
|
*/ |
|
89
|
2 |
|
public function isAutoReload(): bool |
|
90
|
|
|
{ |
|
91
|
2 |
|
return $this->get(self::AUTO_RELOAD, false); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @return int |
|
96
|
|
|
*/ |
|
97
|
2 |
|
public function getOptimization(): int |
|
98
|
|
|
{ |
|
99
|
2 |
|
return $this->get(self::OPTIMIZATIONS, -1); |
|
100
|
|
|
} |
|
101
|
|
|
} |