1 | <?php |
||
23 | class SlotViewHelperService implements SingletonInterface |
||
24 | { |
||
25 | /** |
||
26 | * Contains the closures which will render the registered slots. The keys |
||
27 | * of this array are the names of the slots. |
||
28 | * |
||
29 | * @var Closure[] |
||
30 | */ |
||
31 | private $closures = []; |
||
32 | |||
33 | /** |
||
34 | * @var array[] |
||
35 | */ |
||
36 | private $arguments = []; |
||
37 | |||
38 | /** |
||
39 | * @var RenderingContextInterface|\TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface[] |
||
40 | */ |
||
41 | private $renderingContext = []; |
||
42 | |||
43 | /** |
||
44 | * @var array[] |
||
45 | */ |
||
46 | private $injectedVariables = []; |
||
47 | |||
48 | /** |
||
49 | * @var array[] |
||
50 | */ |
||
51 | private $savedVariables = []; |
||
52 | |||
53 | /** |
||
54 | * Adds a closure - which will render the slot with the given name - to the |
||
55 | * private storage in this class. |
||
56 | * |
||
57 | * @param string $name |
||
58 | * @param Closure $closure |
||
59 | * @param array $arguments |
||
60 | * @param RenderingContextInterface $renderingContext |
||
61 | */ |
||
62 | public function addSlot($name, Closure $closure, array $arguments, RenderingContextInterface $renderingContext) |
||
68 | |||
69 | /** |
||
70 | * Returns the closure which will render the slot with the given name. |
||
71 | * |
||
72 | * @param string $name |
||
73 | * @return Closure |
||
74 | * @throws EntryNotFoundException |
||
75 | */ |
||
76 | public function getSlotClosure($name) |
||
84 | |||
85 | /** |
||
86 | * Returns the closure which will render the slot with the given name. |
||
87 | * |
||
88 | * @param string $name |
||
89 | * @return array |
||
90 | * @throws EntryNotFoundException |
||
91 | */ |
||
92 | public function getSlotArguments($name) |
||
100 | |||
101 | /** |
||
102 | * @param string $name |
||
103 | * @return bool |
||
104 | */ |
||
105 | public function hasSlot($name) |
||
109 | |||
110 | /** |
||
111 | * Will merge the given arguments with the ones registered by the given |
||
112 | * slot, and inject them in the template variable container. |
||
113 | * |
||
114 | * Note that the variables that are already defined are first saved before |
||
115 | * being overridden, so they can be restored later. |
||
116 | * |
||
117 | * @param string $slotName |
||
118 | * @param array $arguments |
||
119 | */ |
||
120 | public function addTemplateVariables($slotName, array $arguments) |
||
142 | |||
143 | /** |
||
144 | * Will remove all variables previously injected in the template variable |
||
145 | * container, and restore the ones that were saved before being overridden. |
||
146 | * |
||
147 | * @param string $slotName |
||
148 | */ |
||
149 | public function restoreTemplateVariables($slotName) |
||
163 | |||
164 | /** |
||
165 | * @param string $slotName |
||
166 | * @return TemplateVariableContainer |
||
167 | */ |
||
168 | protected function getTemplateVariableContainer($slotName) |
||
175 | |||
176 | /** |
||
177 | * Resets the service variables. |
||
178 | */ |
||
179 | public function resetState() |
||
186 | } |
||
187 |