Commit be527945 authored by Stefan Galinski's avatar Stefan Galinski 🎮
Browse files

[BUGFIX] Fix TYPO3 7 compatibility

parent b1d9b666
......@@ -38,34 +38,36 @@ class ExtendedIfViewHelper extends AbstractConditionViewHelper {
*/
public function initializeArguments() {
parent::initializeArguments();
$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.
*
* @return string
*/
public function render() {
if ($this->evaluateConditionFunctionExists()) {
return parent::render();
}
// @todo Remove the following part if only > 7.5 support.
$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();
}
$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
);
}
/**
......@@ -88,16 +90,4 @@ class ExtendedIfViewHelper extends AbstractConditionViewHelper {
return isset($arguments['negate']) && $arguments['negate'] ? !$conditionResult : $conditionResult;
}
/**
* Returns true, if the function evaluateCondition exists in the AbstractConditionViewHelper class.
*
* @deprecated Remove this function if only > 7.5 support.
* @return boolean
*/
protected function evaluateConditionFunctionExists() {
return method_exists('TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper', 'evaluateCondition');
}
}
?>
Markdown is supported
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