From dd790e7c8b19c082ea8b8a4df7934660d0ed5ef6 Mon Sep 17 00:00:00 2001 From: Stefan Bruggmann Date: Wed, 11 Apr 2018 13:10:51 +0200 Subject: [PATCH 1/2] Allow option parsing of arrays (translation.* in neos/form-builder prototypes) and make form values available for the translation. --- Classes/Core/Model/AbstractFinisher.php | 7 ++++++- Classes/Finishers/ConfirmationFinisher.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Classes/Core/Model/AbstractFinisher.php b/Classes/Core/Model/AbstractFinisher.php index 4e09bf7..d8e9fad 100644 --- a/Classes/Core/Model/AbstractFinisher.php +++ b/Classes/Core/Model/AbstractFinisher.php @@ -11,6 +11,7 @@ * source code. */ +use Neos\Utility\Arrays; use Neos\Utility\ObjectAccess; /** @@ -104,7 +105,11 @@ abstract protected function executeInternal(); protected function parseOption($optionName) { if (!isset($this->options[$optionName]) || $this->options[$optionName] === '') { - if (isset($this->defaultOptions[$optionName])) { + if (!is_null(Arrays::getValueByPath($this->options, $optionName)) && Arrays::getValueByPath($this->options, $optionName) !== '') { + $option = Arrays::getValueByPath($this->options, $optionName); + } else if (!is_null(Arrays::getValueByPath($this->defaultOptions, $optionName)) && Arrays::getValueByPath($this->defaultOptions, $optionName) !== '') { + $option = Arrays::getValueByPath($this->defaultOptions, $optionName); + } else if (isset($this->defaultOptions[$optionName])) { $option = $this->defaultOptions[$optionName]; } else { return null; diff --git a/Classes/Finishers/ConfirmationFinisher.php b/Classes/Finishers/ConfirmationFinisher.php index ae8e934..869845a 100644 --- a/Classes/Finishers/ConfirmationFinisher.php +++ b/Classes/Finishers/ConfirmationFinisher.php @@ -87,7 +87,7 @@ protected function executeInternal() $renderingOptions = $formRuntime->getRenderingOptions(); $messagePackageKey = $renderingOptions['translationPackage']; } - $message = $this->translator->translateById($labelId, [], null, $locale, $this->parseOption('translation.source'), $messagePackageKey); + $message = $this->translator->translateById($labelId, $this->finisherContext->getFormValues(), null, $locale, $this->parseOption('translation.source'), $messagePackageKey); } else { $message = $this->parseOption('message'); } From 69ef9c1b09c079f83983e62d1eab5e99c264bca9 Mon Sep 17 00:00:00 2001 From: Stefan Bruggmann Date: Wed, 11 Apr 2018 13:15:04 +0200 Subject: [PATCH 2/2] Fix failing check --- Classes/Core/Model/AbstractFinisher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Core/Model/AbstractFinisher.php b/Classes/Core/Model/AbstractFinisher.php index d8e9fad..fc3b4ec 100644 --- a/Classes/Core/Model/AbstractFinisher.php +++ b/Classes/Core/Model/AbstractFinisher.php @@ -107,9 +107,9 @@ protected function parseOption($optionName) if (!isset($this->options[$optionName]) || $this->options[$optionName] === '') { if (!is_null(Arrays::getValueByPath($this->options, $optionName)) && Arrays::getValueByPath($this->options, $optionName) !== '') { $option = Arrays::getValueByPath($this->options, $optionName); - } else if (!is_null(Arrays::getValueByPath($this->defaultOptions, $optionName)) && Arrays::getValueByPath($this->defaultOptions, $optionName) !== '') { + } elseif (!is_null(Arrays::getValueByPath($this->defaultOptions, $optionName)) && Arrays::getValueByPath($this->defaultOptions, $optionName) !== '') { $option = Arrays::getValueByPath($this->defaultOptions, $optionName); - } else if (isset($this->defaultOptions[$optionName])) { + } elseif (isset($this->defaultOptions[$optionName])) { $option = $this->defaultOptions[$optionName]; } else { return null;