Exemplo n.º 1
0
 /**
  * @param CreateUserRequest $request
  * @param WebServiceUserSession $session
  * @return UserControllerResult
  */
 public function Create($request, $session)
 {
     $errors = $this->requestValidator->ValidateCreateRequest($request);
     if (!empty($errors)) {
         return new UserControllerResult(null, $errors);
     }
     $userService = $this->serviceFactory->CreateAdmin();
     $extraAttributes = array(UserAttribute::Phone => $request->phone, UserAttribute::Organization => $request->organization, UserAttribute::Position => $request->position);
     $customAttributes = array();
     foreach ($request->GetCustomAttributes() as $attribute) {
         $customAttributes[] = new AttributeValue($attribute->attributeId, $attribute->attributeValue);
     }
     $userId = $userService->AddUser($request->userName, $request->emailAddress, $request->firstName, $request->lastName, $request->password, $request->timezone, $request->language, Pages::DEFAULT_HOMEPAGE_ID, $extraAttributes, $customAttributes);
     return new UserControllerResult($userId);
 }