/** * @param ViewHelperVariableContainer $viewHelperVariableContainer * @param string $formClassName * @return DomainObjectInterface|NULL */ protected static function getFormObject($viewHelperVariableContainer, $formClassName = FormViewHelper::class) { if (true === $viewHelperVariableContainer->exists($formClassName, 'formObject')) { return $viewHelperVariableContainer->get($formClassName, 'formObject'); } if (self::ALTERNATE_FORM_VIEWHELPER_CLASSNAME !== $formClassName) { return self::getFormObject($viewHelperVariableContainer, self::ALTERNATE_FORM_VIEWHELPER_CLASSNAME); } return null; }
/** * @test */ public function addOrUpdateWorks() { $this->viewHelperVariableContainer->add('TYPO3\\CMS\\Fluid\\ViewHelper\\NonExistent', 'nonExistentKey', 'value1'); $this->viewHelperVariableContainer->addOrUpdate('TYPO3\\CMS\\Fluid\\ViewHelper\\NonExistent', 'nonExistentKey', 'value2'); $this->assertEquals($this->viewHelperVariableContainer->get('TYPO3\\CMS\\Fluid\\ViewHelper\\NonExistent', 'nonExistentKey'), 'value2'); }
/** * @param ViewHelperVariableContainer $viewHelperVariableContainer * @param string $formClassName * @return DomainObjectInterface|NULL */ protected static function getFormObject($viewHelperVariableContainer, $formClassName = 'Tx_Fluid_ViewHelpers_FormViewHelper') { if (TRUE === $viewHelperVariableContainer->exists($formClassName, 'formObject')) { return $viewHelperVariableContainer->get($formClassName, 'formObject'); } if (self::ALTERNATE_FORM_VIEWHELPER_CLASSNAME !== $formClassName) { return self::getFormObject($viewHelperVariableContainer, self::ALTERNATE_FORM_VIEWHELPER_CLASSNAME); } return NULL; }