1 | <?php |
||
49 | class ViewHelperService |
||
50 | { |
||
51 | /** |
||
52 | * Name of the property where the ViewHelper should be placed |
||
53 | */ |
||
54 | const DEFAULT_PROP_NAME = '_helper'; |
||
55 | |||
56 | /** |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $helpers = array(); |
||
60 | |||
61 | /** |
||
62 | * Should the viewHelper fail silently or throw exceptions? |
||
63 | * |
||
64 | * @var boolean |
||
65 | */ |
||
66 | private $throwExceptions = true; |
||
67 | |||
68 | /** |
||
69 | * The current context |
||
70 | * |
||
71 | * @var Context |
||
72 | */ |
||
73 | protected $context; |
||
74 | |||
75 | /** |
||
76 | * Property of the ViewHelperService in Action's data |
||
77 | * |
||
78 | * @var string |
||
79 | */ |
||
80 | protected $propName = self::DEFAULT_PROP_NAME; |
||
81 | |||
82 | /** |
||
83 | * The running Application |
||
84 | * |
||
85 | * @var Application |
||
86 | */ |
||
87 | protected $application; |
||
88 | |||
89 | /** |
||
90 | * Constructor |
||
91 | * |
||
92 | * @param string $propName Name of the ViewHelperService property |
||
93 | * @param boolean $throwExceptions Should the Service throw exceptions or fail |
||
94 | * silently |
||
95 | * |
||
96 | * @return void |
||
|
|||
97 | */ |
||
98 | 12 | public function __construct($propName = self::DEFAULT_PROP_NAME, |
|
104 | |||
105 | /** |
||
106 | * |
||
107 | * @param string $name |
||
108 | * @param ViewHelper $helper |
||
109 | * |
||
110 | * @return ViewHelperService |
||
111 | */ |
||
112 | 6 | public function add($name, ViewHelper $helper) |
|
119 | |||
120 | /** |
||
121 | * |
||
122 | * @param array $helpers |
||
123 | * |
||
124 | * @return ViewHelperService |
||
125 | */ |
||
126 | 1 | public function addAll(array $helpers) |
|
134 | |||
135 | /** |
||
136 | * |
||
137 | * @param string $helperName |
||
138 | * |
||
139 | * @return ViewHelperService |
||
140 | * @throws Exception if helper not registered |
||
141 | */ |
||
142 | 1 | public function remove($helperName) |
|
152 | |||
153 | /** |
||
154 | * |
||
155 | * @param string $name |
||
156 | * |
||
157 | * @return ViewHelper |
||
158 | * @throws Exception if helper not registered |
||
159 | */ |
||
160 | 8 | public function helper($name) |
|
169 | |||
170 | /** |
||
171 | * |
||
172 | * @param boolean $bool |
||
173 | * |
||
174 | * @return ViewHelper |
||
175 | */ |
||
176 | 3 | public function throwExceptions($bool) |
|
182 | |||
183 | /** |
||
184 | * Tells if the service throws exceptions or fail silently |
||
185 | * |
||
186 | * @return boolean |
||
187 | */ |
||
188 | 1 | public function isThrowExceptions() |
|
192 | |||
193 | /** |
||
194 | * |
||
195 | * @param string $name |
||
196 | * @param mixed $arguments |
||
197 | * |
||
198 | * @return mixed |
||
199 | * @throws Exception (if invalid callback && throwExceptions = true) |
||
200 | */ |
||
201 | 5 | public function __call($name, $arguments) |
|
228 | |||
229 | /** |
||
230 | * |
||
231 | * @param Context $context |
||
232 | * |
||
233 | * @return ViewHelper |
||
234 | */ |
||
235 | 3 | public function setContext(Context $context) |
|
241 | |||
242 | /** |
||
243 | * |
||
244 | * @return Context |
||
245 | */ |
||
246 | public function getContext() |
||
250 | |||
251 | 4 | public function getPropName() |
|
255 | |||
256 | /** |
||
257 | * |
||
258 | * @param string $propName |
||
259 | * |
||
260 | * @return ViewHelperService |
||
261 | */ |
||
262 | 1 | public function setPropName($propName) |
|
268 | |||
269 | /** |
||
270 | * |
||
271 | * @return Application |
||
272 | */ |
||
273 | public function getApplication() |
||
277 | |||
278 | /** |
||
279 | * |
||
280 | * @param Application $application |
||
281 | * |
||
282 | * @return ViewHelperService |
||
283 | */ |
||
284 | 3 | public function setApplication(Application $application) |
|
290 | |||
291 | |||
292 | } |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.