Skip to content

Commit

Permalink
Merge pull request #42 from bwaidelich/41-fix-43-compatibility
Browse files Browse the repository at this point in the history
BUGFIX: Fix Neos 4.3 compatibility
  • Loading branch information
bwaidelich authored Apr 26, 2019
2 parents 5730117 + d490734 commit 3a1c912
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
39 changes: 39 additions & 0 deletions Classes/Fusion/Helper/NodeHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
namespace Neos\Form\Builder\Fusion\Helper;

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\Eel\ProtectedContextAwareInterface;

/**
* Custom Eel Helper for node related functions
*/
class NodeHelper implements ProtectedContextAwareInterface
{

/**
* Merge properties of the specified $node to the given $properties (with precedence to node properties)
*
* Note: This is required since NodeInterface::getProperties() does no longer return an array but an instance of PropertyCollectionInterface
*
* @param array $properties
* @param NodeInterface $node
* @return array
*/
public function mergeProperties(array $properties, NodeInterface $node): array
{
$nodeProperties = $node->getProperties();
if ($nodeProperties instanceof \Traversable) {
$nodeProperties = iterator_to_array($nodeProperties);
}
return array_merge($properties, $nodeProperties);
}

/**
* @param string $methodName
* @return boolean
*/
public function allowsCallOfMethod($methodName): bool
{
return true;
}
}
5 changes: 4 additions & 1 deletion Configuration/Settings.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Neos:
Fusion:
defaultContext:
Neos.Form.Builder.Node: 'Neos\Form\Builder\Fusion\Helper\NodeHelper'
Neos:
fusion:
autoInclude:
Expand Down Expand Up @@ -34,4 +37,4 @@ Neos:
collapsed: false
'form.selectOptions':
label: 'Select options'
collapsed: false
collapsed: false
4 changes: 2 additions & 2 deletions Resources/Private/Fusion/NodeBased/NodeBasedFinisher.fusion
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
prototype(Neos.Form.Builder:NodeBasedFinisher) < prototype(Neos.Fusion:Renderer) {
element {
@context.finisher = ${this}
[email protected] = ${Array.concat(value, finisherNode.properties)}
[email protected] = ${Neos.Form.Builder.Node.mergeProperties(value, finisherNode)}
}
}

Expand All @@ -23,4 +23,4 @@ prototype(Neos.Form.Builder:NodeBasedFinisherCollection) < prototype(Neos.Fusion
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ prototype(Neos.Form.Builder:NodeBasedFormElement) < prototype(Neos.Fusion:Render
label = ${elementNode.properties.label}
required = ${elementNode.properties.required}
defaultValue = ${elementNode.properties.defaultValue}
[email protected] = ${Array.concat(value, elementNode.properties)}
[email protected] = ${Neos.Form.Builder.Node.mergeProperties(value, elementNode)}
validators = Neos.Form.Builder:NodeBasedValidatorCollection {
collection = ${q(elementNode).children('validators').children()}
}
Expand Down Expand Up @@ -43,4 +43,4 @@ prototype(Neos.Form.Builder:NodeBasedElementCollection) < prototype(Neos.Fusion:
}
}
}
}
}
4 changes: 2 additions & 2 deletions Resources/Private/Fusion/NodeBased/NodeBasedValidator.fusion
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
prototype(Neos.Form.Builder:NodeBasedValidator) < prototype(Neos.Fusion:Renderer) {
element {
@context.validator = ${this}
[email protected] = ${Array.concat(value, validatorNode.properties)}
[email protected] = ${Neos.Form.Builder.Node.mergeProperties(value, validatorNode)}
}
}

Expand All @@ -23,4 +23,4 @@ prototype(Neos.Form.Builder:NodeBasedValidatorCollection) < prototype(Neos.Fusio
}
}
}
}
}

0 comments on commit 3a1c912

Please sign in to comment.