Beispiel #1
0
 /**
  * Updates a user
  *
  * @param $userId
  *
  * @return \eZ\Publish\Core\REST\Server\Values\RestUser
  */
 public function updateUser($userId)
 {
     $user = $this->userService->loadUser($userId);
     $updateStruct = $this->inputDispatcher->parse(new Message(array('Content-Type' => $this->request->headers->get('Content-Type'), 'Url' => $this->request->getPathInfo()), $this->request->getContent()));
     if ($updateStruct->sectionId !== null) {
         $section = $this->sectionService->loadSection($updateStruct->sectionId);
         $this->sectionService->assignSection($user->getVersionInfo()->getContentInfo(), $section);
     }
     $updatedUser = $this->userService->updateUser($user, $updateStruct->userUpdateStruct);
     $updatedContentInfo = $updatedUser->getVersionInfo()->getContentInfo();
     $mainLocation = $this->locationService->loadLocation($updatedContentInfo->mainLocationId);
     $contentType = $this->contentTypeService->loadContentType($updatedContentInfo->contentTypeId);
     return new Values\RestUser($updatedUser, $contentType, $updatedContentInfo, $mainLocation, $this->contentService->loadRelations($updatedUser->getVersionInfo()));
 }
 /**
  * Updates a user
  *
  * 4.x: If the versionUpdateStruct is set in the user update structure, this method internally creates a content draft, updates ts with the provided data
  * and publishes the draft. If a draft is explicitly required, the user group can be updated via the content service methods.
  *
  * @param \eZ\Publish\API\Repository\Values\User\User $user
  * @param \eZ\Publish\API\Repository\Values\User\UserUpdateStruct $userUpdateStruct
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update the user
  * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userUpdateStruct is not valid
  * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set empty
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a field value is not accepted by the field type
  *
  * @return \eZ\Publish\API\Repository\Values\User\User
  */
 public function updateUser(User $user, UserUpdateStruct $userUpdateStruct)
 {
     $returnValue = $this->service->updateUser($user, $userUpdateStruct);
     $this->signalDispatcher->emit(new UpdateUserSignal(array('userId' => $user->id)));
     return $returnValue;
 }