|
1
|
|
|
<?php |
|
2
|
|
|
namespace TYPO3Fluid\Fluid\Core\Parser; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file belongs to the package "TYPO3 Fluid". |
|
6
|
|
|
* See LICENSE.txt that was shipped with this package. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* The parser configuration. Contains all configuration needed to configure |
|
11
|
|
|
* the building of a SyntaxTree. |
|
12
|
|
|
*/ |
|
13
|
|
|
class Configuration |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var bool |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $viewHelperArgumentEscapingEnabled = true; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Generic interceptors registered with the configuration. |
|
22
|
|
|
* |
|
23
|
|
|
* @var \SplObjectStorage[] |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $interceptors = []; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Escaping interceptors registered with the configuration. |
|
29
|
|
|
* |
|
30
|
|
|
* @var \SplObjectStorage[] |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $escapingInterceptors = []; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @return bool |
|
36
|
|
|
*/ |
|
37
|
|
|
public function isViewHelperArgumentEscapingEnabled() |
|
38
|
|
|
{ |
|
39
|
|
|
return $this->viewHelperArgumentEscapingEnabled; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param bool $viewHelperArgumentEscapingEnabled |
|
44
|
|
|
*/ |
|
45
|
|
|
public function setViewHelperArgumentEscapingEnabled($viewHelperArgumentEscapingEnabled): void |
|
46
|
|
|
{ |
|
47
|
|
|
$this->viewHelperArgumentEscapingEnabled = (bool) $viewHelperArgumentEscapingEnabled; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Adds an interceptor to apply to values coming from object accessors. |
|
52
|
|
|
* |
|
53
|
|
|
* @param InterceptorInterface $interceptor |
|
54
|
|
|
* @return void |
|
55
|
|
|
*/ |
|
56
|
|
|
public function addInterceptor(InterceptorInterface $interceptor) |
|
57
|
|
|
{ |
|
58
|
|
|
$this->addInterceptorToArray($interceptor, $this->interceptors); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Adds an escaping interceptor to apply to values coming from object accessors if escaping is enabled |
|
63
|
|
|
* |
|
64
|
|
|
* @param InterceptorInterface $interceptor |
|
65
|
|
|
* @return void |
|
66
|
|
|
*/ |
|
67
|
|
|
public function addEscapingInterceptor(InterceptorInterface $interceptor) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->addInterceptorToArray($interceptor, $this->escapingInterceptors); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Adds an interceptor to apply to values coming from object accessors. |
|
74
|
|
|
* |
|
75
|
|
|
* @param InterceptorInterface $interceptor |
|
76
|
|
|
* @param \SplObjectStorage[] $interceptorArray |
|
77
|
|
|
* @return void |
|
78
|
|
|
*/ |
|
79
|
|
|
protected function addInterceptorToArray(InterceptorInterface $interceptor, array &$interceptorArray) |
|
80
|
|
|
{ |
|
81
|
|
|
foreach ($interceptor->getInterceptionPoints() as $interceptionPoint) { |
|
82
|
|
|
if (!isset($interceptorArray[$interceptionPoint])) { |
|
83
|
|
|
$interceptorArray[$interceptionPoint] = new \SplObjectStorage(); |
|
84
|
|
|
} |
|
85
|
|
|
$interceptors = $interceptorArray[$interceptionPoint]; |
|
86
|
|
|
if (!$interceptors->contains($interceptor)) { |
|
87
|
|
|
$interceptors->attach($interceptor); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Returns all interceptors for a given Interception Point. |
|
94
|
|
|
* |
|
95
|
|
|
* @param integer $interceptionPoint one of the InterceptorInterface::INTERCEPT_* constants, |
|
96
|
|
|
* @return InterceptorInterface[] |
|
97
|
|
|
*/ |
|
98
|
|
|
public function getInterceptors($interceptionPoint) |
|
99
|
|
|
{ |
|
100
|
|
|
return isset($this->interceptors[$interceptionPoint]) ? $this->interceptors[$interceptionPoint] : new \SplObjectStorage(); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Returns all escaping interceptors for a given Interception Point. |
|
105
|
|
|
* |
|
106
|
|
|
* @param integer $interceptionPoint one of the InterceptorInterface::INTERCEPT_* constants, |
|
107
|
|
|
* @return InterceptorInterface[] |
|
108
|
|
|
*/ |
|
109
|
|
|
public function getEscapingInterceptors($interceptionPoint) |
|
110
|
|
|
{ |
|
111
|
|
|
return isset($this->escapingInterceptors[$interceptionPoint]) ? $this->escapingInterceptors[$interceptionPoint] : new \SplObjectStorage(); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|