| @@ 38-67 (lines=30) @@ | ||
| 35 | * |
|
| 36 | * @api |
|
| 37 | */ |
|
| 38 | class ArgumentViewHelper extends AbstractViewHelper |
|
| 39 | { |
|
| 40 | use CompileWithContentArgumentAndRenderStatic; |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @return void |
|
| 44 | */ |
|
| 45 | public function initializeArguments() |
|
| 46 | { |
|
| 47 | $this->registerArgument('value', 'mixed', 'Value to assign. If not in arguments then taken from tag content'); |
|
| 48 | $this->registerArgument('name', 'string', 'Name of variable to create', true); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @param array $arguments |
|
| 53 | * @param \Closure $renderChildrenClosure |
|
| 54 | * @param RenderingContextInterface $renderingContext |
|
| 55 | * @return null |
|
| 56 | */ |
|
| 57 | public static function renderStatic( |
|
| 58 | array $arguments, |
|
| 59 | \Closure $renderChildrenClosure, |
|
| 60 | RenderingContextInterface $renderingContext |
|
| 61 | ) { |
|
| 62 | if ($delegateVariableProvider = $renderingContext->getViewHelperVariableContainer()->getTopmostDelegateVariableProvider()) { |
|
| 63 | $delegateVariableProvider->add($arguments['name'], $renderChildrenClosure()); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| 67 | } |
|
| 68 | ||
| @@ 34-62 (lines=29) @@ | ||
| 31 | * @see \TYPO3Fluid\Fluid\ViewHelpers\IfViewHelper |
|
| 32 | * @api |
|
| 33 | */ |
|
| 34 | class VariableViewHelper extends AbstractViewHelper |
|
| 35 | { |
|
| 36 | use CompileWithContentArgumentAndRenderStatic; |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @return void |
|
| 40 | */ |
|
| 41 | public function initializeArguments() |
|
| 42 | { |
|
| 43 | $this->registerArgument('value', 'mixed', 'Value to assign. If not in arguments then taken from tag content'); |
|
| 44 | $this->registerArgument('name', 'string', 'Name of variable to create', true); |
|
| 45 | } |
|
| 46 | ||
| 47 | /** |
|
| 48 | * @param array $arguments |
|
| 49 | * @param \Closure $renderChildrenClosure |
|
| 50 | * @param RenderingContextInterface $renderingContext |
|
| 51 | * @return null |
|
| 52 | */ |
|
| 53 | public static function renderStatic( |
|
| 54 | array $arguments, |
|
| 55 | \Closure $renderChildrenClosure, |
|
| 56 | RenderingContextInterface $renderingContext |
|
| 57 | ) { |
|
| 58 | $value = $renderChildrenClosure(); |
|
| 59 | $renderingContext->getVariableProvider()->add($arguments['name'], $value); |
|
| 60 | } |
|
| 61 | ||
| 62 | } |
|
| 63 | ||