Skip to content

Commit

Permalink
Merge pull request #166 from neos/bugfix/rendervalues-php8-compat
Browse files Browse the repository at this point in the history
BUGFIX: Fix RenderValuesViewHelper PHP 8+ compatibility
  • Loading branch information
bwaidelich authored Sep 19, 2022
2 parents b417889 + 9c13aea commit 97828f1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Classes/ViewHelpers/RenderValuesViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public function render(): string
*/
protected function processElementValue(FormElementInterface $element, $value)
{
if (is_object($value)) {
return $this->processObject($element, $value);
}
$properties = $element->getProperties();
if (isset($properties['options']) && is_array($properties['options'])) {
if (is_array($value)) {
Expand All @@ -104,9 +107,6 @@ protected function processElementValue(FormElementInterface $element, $value)

return $this->mapValueToOption($value, $properties['options']);
}
if (is_object($value)) {
return $this->processObject($element, $value);
}
return $value;
}

Expand Down Expand Up @@ -151,14 +151,14 @@ protected function mapValueToOption($value, array $options): string
protected function processObject(FormElementInterface $element, $object): string
{
$properties = $element->getProperties();
if ($object instanceof \DateTime) {
if ($object instanceof \DateTimeInterface) {
if (isset($properties['dateFormat'])) {
$dateFormat = $properties['dateFormat'];
if (isset($properties['displayTimeSelector']) && $properties['displayTimeSelector'] === true) {
$dateFormat .= ' H:i';
}
} else {
$dateFormat = \DateTime::W3C;
$dateFormat = \DateTimeInterface::W3C;
}
return $object->format($dateFormat);
}
Expand Down

0 comments on commit 97828f1

Please sign in to comment.