Exemple #1
0
 public function save(UserDto $userDto)
 {
     $qUserDto = new UserDto();
     $qUserDto->setScenario('admin-query');
     $user = $this->findById($userDto->id);
     if ($user->load(['User' => ArrayHelper::toArray($userDto)])) {
         $user->setPassword($userDto->password);
         $user->generateAuthKey();
         $user->generatePasswordResetToken();
         $user->save();
         return ArrayHelper::toArray($user, ['common\\models\\User' => $qUserDto->activeAttributes()]);
     } else {
         return [];
     }
 }
Exemple #2
0
 public function actionRestQuery()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $params = Yii::$app->request->post();
     $userDto = new UserDto();
     $userDto->setScenario('admin-query');
     $userDto->load(['UserDto' => $params]);
     $ds = $this->userService->query($userDto, ['pageParam' => 'pageCurrent', 'pageSizeParam' => 'pageSize', 'defaultPageSize' => $this->pageParams['pageSize'], 'route' => Yii::$app->requestedRoute, 'params' => $this->pageParams], [$this->sortParams['orderField'] => $this->sortParams['orderDirection']]);
     return $ds;
 }