@@ -44,6 +44,7 @@ public function __construct()
4444 'array_append ' => function ($ operand , $ v , $ x ) {
4545 $ operand ->validateScalarArray ($ v );
4646 $ v [] = $ x ;
47+
4748 return $ v ;
4849 },
4950 'array ' => function () {
@@ -85,45 +86,20 @@ public function __construct()
8586 public function updateNode (RowInterface $ row , $ propertyData )
8687 {
8788 $ node = $ row ->getNode ($ propertyData ['selector ' ]);
88-
89- if ($ node ->hasProperty ($ propertyData ['name ' ])) {
90- $ value = $ this ->handleExisting ($ row , $ node , $ propertyData );
91- } else {
92- $ value = $ propertyData ['value ' ];
93- }
94-
95- $ node ->setProperty ($ propertyData ['name ' ], $ value );
96- }
97-
98- private function handleExisting ($ row , $ node , $ propertyData )
99- {
100- $ phpcrProperty = $ node ->getProperty ($ propertyData ['name ' ]);
10189 $ value = $ propertyData ['value ' ];
10290
10391 if ($ value instanceof FunctionOperand) {
104- return $ this ->handleFunction ($ row, $ node , $ phpcrProperty , $ propertyData );
92+ $ value = $ this ->handleFunction ($ row , $ propertyData );
10593 }
10694
107- return $ value ;
95+ $ node -> setProperty ( $ propertyData [ ' name ' ], $ value) ;
10896 }
10997
110- private function handleFunction ($ row , $ node , $ phpcrProperty , $ propertyData )
98+ private function handleFunction ($ row , $ propertyData )
11199 {
112- $ currentValue = $ phpcrProperty ->getValue ();
113100 $ value = $ propertyData ['value ' ];
114-
115101 $ value = $ value ->execute ($ this ->functionMap , $ row );
116102
117- if ($ phpcrProperty ->isMultiple ()) {
118- // do not allow updating multivalue with scalar
119- if (false === is_array ($ value ) && sizeof ($ currentValue ) > 1 ) {
120- throw new \InvalidArgumentException (sprintf (
121- '<error>Cannot update multivalue property "%s" with a scalar value.</error> ' ,
122- $ phpcrProperty ->getName ()
123- ));
124- }
125- }
126-
127103 return $ value ;
128104 }
129105}
0 commit comments