@@ 54-70 (lines=17) @@ | ||
51 | $servletRequest = $this->getServletRequest(); |
|
52 | ||
53 | // try to inject the request parameters by using the class setters |
|
54 | foreach ($servletRequest->getParameterMap() as $key => $value) { |
|
55 | // prepare the setter method name |
|
56 | $methodName = sprintf('set%s', ucfirst($key)); |
|
57 | ||
58 | // query whether the class has the setter implemented |
|
59 | if (in_array($methodName, $methods) === false) { |
|
60 | continue; |
|
61 | } |
|
62 | ||
63 | try { |
|
64 | // set the value by using the setter |
|
65 | $action->$methodName($value); |
|
66 | ||
67 | } catch (\Exception $e) { |
|
68 | $action->addFieldError($key, $e->getMessage()); |
|
69 | } |
|
70 | } |
|
71 | ||
72 | // proceed invocation chain |
|
73 | return $methodInvocation->proceed(); |
@@ 61-77 (lines=17) @@ | ||
58 | // only process if request has valid JSON |
|
59 | if (is_object(json_decode($bodyContent))) { |
|
60 | // try to inject the request parameters by using the class setters |
|
61 | foreach (json_decode($bodyContent) as $key => $value) { |
|
62 | // prepare the setter method name |
|
63 | $methodName = sprintf('set%s', ucfirst($key)); |
|
64 | ||
65 | // query whether the class has the setter implemented |
|
66 | if (in_array($methodName, $methods) === false) { |
|
67 | continue; |
|
68 | } |
|
69 | ||
70 | try { |
|
71 | // set the value by using the setter |
|
72 | $action->$methodName($value); |
|
73 | ||
74 | } catch (\Exception $e) { |
|
75 | $action->addFieldError($key, $e->getMessage()); |
|
76 | } |
|
77 | } |
|
78 | } |
|
79 | } |
|
80 |