/**
  * Saves content draft corresponding to $data.
  * Depending on the nature of $data (create or update data), the draft will either be created or simply updated.
  *
  * @param ContentStruct|\EzSystems\RepositoryForms\Data\User\UserCreateData $data
  * @param $languageCode
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Content
  */
 private function saveDraft(UserCreateData $data, $languageCode)
 {
     foreach ($data->fieldsData as $fieldDefIdentifier => $fieldData) {
         if ($fieldData->getFieldTypeIdentifier() !== 'ezuser') {
             $data->setField($fieldDefIdentifier, $fieldData->value, $languageCode);
         }
     }
     return $this->repository->sudo(function () use($data) {
         return $this->userService->createUser($data, $data->getParentGroups());
     });
 }
 /**
  * @return UserCreateData
  */
 public function mapToFormData()
 {
     $resolver = new OptionsResolver();
     $this->configureOptions($resolver);
     $this->params = $resolver->resolve($this->params);
     $contentType = $this->contentTypeLoader->loadContentType();
     $data = new UserCreateData(['contentType' => $contentType, 'mainLanguageCode' => $this->params['language']]);
     $data->addParentGroup($this->parentGroupLoader->loadGroup());
     foreach ($contentType->fieldDefinitions as $fieldDef) {
         $data->addFieldData(new FieldData(['fieldDefinition' => $fieldDef, 'field' => new Field(['fieldDefIdentifier' => $fieldDef->identifier, 'languageCode' => $this->params['language']]), 'value' => $fieldDef->defaultValue]));
     }
     return $data;
 }