Commit 316445e2 authored by Markus Klein's avatar Markus Klein
Browse files

[BUGFIX] Make ExtendedIfViewHelper PHP7 compatible

parent 0ac894b9
......@@ -32,35 +32,37 @@ use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
* ExtendedIfViewHelper
*/
class ExtendedIfViewHelper extends AbstractConditionViewHelper {
/**
* Initializes the "then" and "else" arguments
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('condition', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE);
$this->registerArgument('or', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE);
$this->registerArgument('or2', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE);
$this->registerArgument('or3', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE);
$this->registerArgument('or4', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE);
$this->registerArgument('and', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, TRUE);
$this->registerArgument('and2', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, TRUE);
$this->registerArgument('and3', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, TRUE);
$this->registerArgument('and4', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, TRUE);
$this->registerArgument('negate', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE);
}
/**
* renders <f:then> child if $condition or $or is true, otherwise renders <f:else> child.
*
* Note: The phpdoc data type of the parameter must be named "boolean".
* Otherwise Fluid doesn't evaluates conditions itself.
*
* @param boolean $condition
* @param boolean $or
* @param boolean $or2
* @param boolean $or3
* @param boolean $or4
* @param boolean $and
* @param boolean $and2
* @param boolean $and3
* @param boolean $and4
* @param boolean $negate
* @return string
*/
public function render(
$condition, $or = FALSE, $or2 = FALSE, $or3 = FALSE, $or4 = FALSE,
$and = TRUE, $and2 = TRUE, $and3 = TRUE, $and4 = TRUE, $negate = FALSE
) {
public function render() {
if ($this->evaluateConditionFunctionExists()) {
return parent::render();
}
// @todo Remove the following part if only > 7.5 support.
$conditionResult = ($condition || $or || $or2 || $or3 || $or4) && $and && $and2 && $and3 && $and4;
if ($negate ? !$conditionResult : $conditionResult) {
$conditionResult = ($this->arguments['condition'] || $this->arguments['or'] || $this->arguments['or2'] || $this->arguments['or3'] || $this->arguments['or4'])
&& $this->arguments['and'] && $this->arguments['and2'] && $this->arguments['and3'] && $this->arguments['and4'];
if ($this->arguments['negate'] ? !$conditionResult : $conditionResult) {
return $this->renderThenChild();
} else {
return $this->renderElseChild();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment