@@ -55,7 +55,7 @@ public function one(array $data, array $options = [])
5555 $ resourceClass = $ this ->_endpoint ->resourceClass ();
5656 /* @var \Muffin\Webservice\Model\Resource $entity */
5757 $ entity = new $ resourceClass ();
58- $ entity ->source ($ this ->_endpoint ->registryAlias ());
58+ $ entity ->setSource ($ this ->_endpoint ->registryAlias ());
5959
6060 if (isset ($ options ['accessibleFields ' ])) {
6161 foreach ((array )$ options ['accessibleFields ' ] as $ key => $ value ) {
@@ -79,7 +79,7 @@ public function one(array $data, array $options = [])
7979
8080 if (!isset ($ options ['fieldList ' ])) {
8181 $ entity ->set ($ properties );
82- $ entity ->errors ($ errors );
82+ $ entity ->setErrors ($ errors );
8383
8484 return $ entity ;
8585 }
@@ -106,22 +106,23 @@ public function one(array $data, array $options = [])
106106 */
107107 protected function _validate ($ data , $ options , $ isNew )
108108 {
109- if (!$ options ['validate ' ]) {
110- return [];
111- }
109+ $ validator = null ;
110+
112111 if ($ options ['validate ' ] === true ) {
113- $ options ['validate ' ] = $ this ->_endpoint ->validator ('default ' );
112+ $ validator = $ this ->_endpoint ->getValidator ('default ' );
113+ } elseif (is_string ($ options ['validate ' ])) {
114+ $ validator = $ this ->_endpoint ->getValidator ($ options ['validate ' ]);
115+ } elseif (is_object ($ options ['validate ' ])) {
116+ $ validator = $ options ['validate ' ];
114117 }
115- if (is_string ($ options ['validate ' ])) {
116- $ options ['validate ' ] = $ this ->_endpoint ->validator ($ options ['validate ' ]);
117- }
118- if (!is_object ($ options ['validate ' ])) {
118+
119+ if ($ validator === null ) {
119120 throw new RuntimeException (
120121 sprintf ('validate must be a boolean, a string or an object. Got %s. ' , gettype ($ options ['validate ' ]))
121122 );
122123 }
123124
124- return $ options [ ' validate ' ] ->errors ($ data , $ isNew );
125+ return $ validator ->errors ($ data , $ isNew );
125126 }
126127
127128 /**
0 commit comments