@@ -293,42 +293,43 @@ protected function _createFromArray($className, $data)
293293 // Converts snake_case to uppercase CamelCase to help form getter/setter method names
294294 // This use case is for REST only. SOAP request data is already camel cased
295295 $ camelCaseProperty = SimpleDataObjectConverter::snakeCaseToUpperCamelCase ($ propertyName );
296+ $ methodName = 'get ' .$ camelCaseProperty ;
296297 try {
297298 $ methodName = $ this ->getNameFinder ()->getGetterMethodName ($ class , $ camelCaseProperty );
298- if (!isset ($ this ->methodReflectionStorage [$ className . $ methodName ])) {
299- $ this ->methodReflectionStorage [$ className . $ methodName ] = $ class ->getMethod ($ methodName );
300- }
301- $ methodReflection = $ this ->methodReflectionStorage [$ className . $ methodName ];
302- if ($ methodReflection ->isPublic ()) {
303- $ returnType = $ this ->typeProcessor ->getGetterReturnType ($ methodReflection )['type ' ];
304- try {
305- $ setterName = $ this ->getNameFinder ()->getSetterMethodName ($ class , $ camelCaseProperty );
306- } catch (\Exception $ e ) {
307- if (empty ($ value )) {
308- continue ;
309- } else {
310- throw $ e ;
311- }
299+ } catch (\LogicException $ e ) {
300+ $ this ->processInputErrorForNestedSet ([$ camelCaseProperty ]);
301+ }
302+ if (!isset ($ this ->methodReflectionStorage [$ className . $ methodName ])) {
303+ $ this ->methodReflectionStorage [$ className . $ methodName ] = $ class ->getMethod ($ methodName );
304+ }
305+ $ methodReflection = $ this ->methodReflectionStorage [$ className . $ methodName ];
306+ if ($ methodReflection ->isPublic ()) {
307+ $ returnType = $ this ->typeProcessor ->getGetterReturnType ($ methodReflection )['type ' ];
308+ try {
309+ $ setterName = $ this ->getNameFinder ()->getSetterMethodName ($ class , $ camelCaseProperty );
310+ } catch (\Exception $ e ) {
311+ if (empty ($ value )) {
312+ continue ;
313+ } else {
314+ throw $ e ;
312315 }
313- try {
314- if ($ camelCaseProperty === 'CustomAttributes ' ) {
315- $ setterValue = $ this ->convertCustomAttributeValue ($ value , $ className );
316- } else {
317- $ setterValue = $ this ->convertValue ($ value , $ returnType );
318- }
319- } catch (SerializationException $ e ) {
320- throw new SerializationException (
321- new Phrase (
322- 'Error occurred during "%field_name" processing. %details ' ,
323- ['field_name ' => $ propertyName , 'details ' => $ e ->getMessage ()]
324- )
325- );
316+ }
317+ try {
318+ if ($ camelCaseProperty === 'CustomAttributes ' ) {
319+ $ setterValue = $ this ->convertCustomAttributeValue ($ value , $ className );
320+ } else {
321+ $ setterValue = $ this ->convertValue ($ value , $ returnType );
326322 }
327- $ this ->serviceInputValidator ->validateEntityValue ($ object , $ propertyName , $ setterValue );
328- $ object ->{$ setterName }($ setterValue );
323+ } catch (SerializationException $ e ) {
324+ throw new SerializationException (
325+ new Phrase (
326+ 'Error occurred during "%field_name" processing. %details ' ,
327+ ['field_name ' => $ propertyName , 'details ' => $ e ->getMessage ()]
328+ )
329+ );
329330 }
330- } catch ( \ LogicException $ e ) {
331- $ this -> processUnsupportedParameter ([ $ camelCaseProperty ] );
331+ $ this -> serviceInputValidator -> validateEntityValue ( $ object , $ propertyName , $ setterValue );
332+ $ object ->{ $ setterName }( $ setterValue );
332333 }
333334 }
334335
@@ -581,20 +582,20 @@ protected function processInputError($inputError)
581582 }
582583
583584 /**
584- * Process unsupported parameter input error
585+ * Process an input error for child parameters
585586 *
586587 * @param array $inputError
587588 * @return void
588589 * @throws InputException
589590 */
590- private function processUnsupportedParameter (array $ inputError ): void
591+ private function processInputErrorForNestedSet (array $ inputError ): void
591592 {
592593 if (!empty ($ inputError )) {
593594 $ exception = new InputException ();
594595 foreach ($ inputError as $ errorParamField ) {
595596 $ exception ->addError (
596597 new Phrase (
597- '" ' . $ errorParamField . ' " is not supported. Correct the field name and try again. ' ,
598+ '"%fieldName " is not supported. Correct the field name and try again. ' ,
598599 ['fieldName ' => $ errorParamField ]
599600 )
600601 );
0 commit comments