1
|
|
|
<?php |
2
|
|
|
namespace TYPO3Fluid\Fluid\Core\ViewHelper; |
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
|
|
|
* Argument definition of each view helper argument |
11
|
|
|
*/ |
12
|
|
|
class ArgumentDefinition |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Name of argument |
17
|
|
|
* |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected $name; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Type of argument |
24
|
|
|
* |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $type; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Description of argument |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $description; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Is argument required? |
38
|
|
|
* |
39
|
|
|
* @var boolean |
40
|
|
|
*/ |
41
|
|
|
protected $required = false; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Default value for argument |
45
|
|
|
* |
46
|
|
|
* @var mixed |
47
|
|
|
*/ |
48
|
|
|
protected $defaultValue = null; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Escaping instruction, in line with $this->escapeOutput / $this->escapeChildren on ViewHelpers. |
52
|
|
|
* |
53
|
|
|
* A value of NULL means "use default behavior" (which is to escape nodes contained in the value). |
54
|
|
|
* |
55
|
|
|
* A value of TRUE means "escape unless escaping is disabled" (e.g. if argument is used in a ViewHelper nested |
56
|
|
|
* within f:format.raw which disables escaping, the argument will not be escaped). |
57
|
|
|
* |
58
|
|
|
* A value of FALSE means "never escape argument" (as in behavior of f:format.raw, which supports both passing |
59
|
|
|
* argument as actual argument or as tag content, but wants neither to be escaped). |
60
|
|
|
* |
61
|
|
|
* @var bool|null |
62
|
|
|
*/ |
63
|
|
|
protected $escape = null; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Constructor for this argument definition. |
67
|
|
|
* |
68
|
|
|
* @param string $name Name of argument |
69
|
|
|
* @param string $type Type of argument |
70
|
|
|
* @param string $description Description of argument |
71
|
|
|
* @param boolean $required TRUE if argument is required |
72
|
|
|
* @param mixed $defaultValue Default value |
73
|
|
|
* @param bool|null $escape Whether or not argument is escaped, or uses default escaping behavior (see class var comment) |
74
|
|
|
*/ |
75
|
|
|
public function __construct($name, $type, $description, $required, $defaultValue = null, $escape = null) |
76
|
|
|
{ |
77
|
|
|
$this->name = $name; |
78
|
|
|
$this->type = $type; |
79
|
|
|
$this->description = $description; |
80
|
|
|
$this->required = $required; |
81
|
|
|
$this->defaultValue = $defaultValue; |
82
|
|
|
$this->escape = $escape; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Get the name of the argument |
87
|
|
|
* |
88
|
|
|
* @return string Name of argument |
89
|
|
|
*/ |
90
|
|
|
public function getName() |
91
|
|
|
{ |
92
|
|
|
return $this->name; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Get the type of the argument |
97
|
|
|
* |
98
|
|
|
* @return string Type of argument |
99
|
|
|
*/ |
100
|
|
|
public function getType() |
101
|
|
|
{ |
102
|
|
|
return $this->type; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Get the description of the argument |
107
|
|
|
* |
108
|
|
|
* @return string Description of argument |
109
|
|
|
*/ |
110
|
|
|
public function getDescription() |
111
|
|
|
{ |
112
|
|
|
return $this->description; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Get the optionality of the argument |
117
|
|
|
* |
118
|
|
|
* @return boolean TRUE if argument is optional |
119
|
|
|
*/ |
120
|
|
|
public function isRequired() |
121
|
|
|
{ |
122
|
|
|
return $this->required; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Get the default value, if set |
127
|
|
|
* |
128
|
|
|
* @return mixed Default value |
129
|
|
|
*/ |
130
|
|
|
public function getDefaultValue() |
131
|
|
|
{ |
132
|
|
|
return $this->defaultValue; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @return bool|null |
137
|
|
|
*/ |
138
|
|
|
public function getEscape() |
139
|
|
|
{ |
140
|
|
|
return $this->escape; |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|