1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Micro framework package. |
5
|
|
|
* |
6
|
|
|
* (c) Stanislau Komar <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Micro\Plugin\Twig; |
13
|
|
|
|
14
|
|
|
use Micro\Framework\Kernel\Configuration\PluginConfiguration; |
15
|
|
|
|
16
|
|
|
class TwigPluginConfiguration extends PluginConfiguration implements TwigPluginConfigurationInterface |
17
|
|
|
{ |
18
|
|
|
protected const CFG_CHARSET = 'TWIG_CHARSET'; |
19
|
|
|
protected const CFG_IS_DEBUG = 'TWIG_DEBUG'; |
20
|
|
|
protected const CFG_CACHE = 'TWIG_CACHE'; |
21
|
|
|
protected const CFG_IS_AUTO_RELOAD = 'TWIG_AUTO_RELOAD'; |
22
|
|
|
protected const CFG_IS_STRICT_VARIABLES = 'TWIG_STRICT_VARIABLES'; |
23
|
|
|
protected const CFG_OPTIMIZATIONS = 'TWIG_OPTIMIZATIONS'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* {@inheritdoc} |
27
|
|
|
*/ |
28
|
1 |
|
public function getConfigurationArray(): array |
29
|
|
|
{ |
30
|
1 |
|
return [ |
31
|
1 |
|
'debug' => $this->isDebug(), |
32
|
1 |
|
'charset' => $this->getCharset(), |
33
|
1 |
|
'cache' => $this->getCachePath() ?? false, |
34
|
1 |
|
'auto_reload' => $this->isAutoReload(), |
35
|
1 |
|
'strict_variables' => $this->isStrictVariables(), |
36
|
1 |
|
'optimizations' => $this->getOptimizations(), |
37
|
1 |
|
]; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritdoc} |
42
|
|
|
*/ |
43
|
1 |
|
public function isDebug(): bool |
44
|
|
|
{ |
45
|
1 |
|
return (bool) $this->configuration->get(self::CFG_IS_DEBUG, self::IS_DEBUG_DEFAULT); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* {@inheritdoc} |
50
|
|
|
*/ |
51
|
1 |
|
public function getCharset(): string |
52
|
|
|
{ |
53
|
1 |
|
return (string) $this->configuration->get(self::CFG_CHARSET, self::CHARSET_DEFAULT); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
*/ |
59
|
1 |
|
public function getCachePath(): ?string |
60
|
|
|
{ |
61
|
|
|
/* @var string|null */ |
62
|
1 |
|
return $this->configuration->get(self::CFG_CACHE, self::CACHE_DEFAULT); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* {@inheritdoc} |
67
|
|
|
*/ |
68
|
1 |
|
public function isAutoReload(): bool |
69
|
|
|
{ |
70
|
1 |
|
return (bool) $this->configuration->get(self::CFG_IS_AUTO_RELOAD, self::IS_AUTO_RELOAD_DEFAULT); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* {@inheritdoc} |
75
|
|
|
*/ |
76
|
1 |
|
public function isStrictVariables(): bool |
77
|
|
|
{ |
78
|
1 |
|
return (bool) $this->configuration->get(self::CFG_IS_STRICT_VARIABLES, self::IS_STRICT_VARIABLES_DEFAULT); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* {@inheritdoc} |
83
|
|
|
*/ |
84
|
1 |
|
public function getOptimizations(): int |
85
|
|
|
{ |
86
|
1 |
|
return (int) $this->configuration->get(self::CFG_OPTIMIZATIONS, self::OPTIMIZATIONS_DEFAULT); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|