Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-3265: Disabled User account form during translation #61

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bundle/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function editAction(
string $language,
Request $request
) {
$user = $this->userService->loadUser($contentId);
$user = $this->userService->loadUser($contentId, [$language]);
if (!$this->permissionResolver->canUser('content', 'edit', $user)) {
throw new CoreUnauthorizedException('content', 'edit', ['userId' => $contentId]);
}
Expand Down
16 changes: 8 additions & 8 deletions src/lib/FieldType/Mapper/UserAccountFieldValueFormMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
use eZ\Publish\Core\FieldType\User\Value as ApiUserValue;
use EzSystems\EzPlatformContentForms\Data\Content\ContentUpdateData;
use EzSystems\EzPlatformContentForms\Data\Content\FieldData;
use EzSystems\EzPlatformContentForms\Data\ContentTranslationData;
use EzSystems\EzPlatformContentForms\Data\User\UserAccountFieldData;
use EzSystems\EzPlatformContentForms\FieldType\FieldValueFormMapperInterface;
use EzSystems\EzPlatformContentForms\Form\Type\FieldType\UserAccountFieldType;
Expand Down Expand Up @@ -46,22 +46,22 @@ public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data)
$formConfig = $fieldForm->getConfig();
$rootForm = $fieldForm->getRoot()->getRoot();
$formIntent = $rootForm->getConfig()->getOption('intent');
$isTranslation = $rootForm->getData() instanceof ContentTranslationData;
$formData = $rootForm->getData();
if ($formData instanceof ContentUpdateData) {
return;
}

$formBuilder = $formConfig->getFormFactory()->createBuilder()
->create('value', UserAccountFieldType::class, [
'required' => true,
'label' => $fieldDefinition->getName(),
'intent' => $formIntent,
'constraints' => [
new UserAccountPassword(['contentType' => $rootForm->getData()->contentType]),
new UserAccountPassword(['contentType' => $formData->contentType]),
],
]);

if ($isTranslation) {
$formBuilder->addModelTransformer($this->getModelTransformerForTranslation($fieldDefinition));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getModelTransformerForTranslation method should be deprecated as it's not used anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamwojs could you, please, take a look at #61 (comment)? This PR has to be put on hold until we decide what to do with content translating, as discussed:
Creating - userCreateData (instead of contentCreateData)
Updating - userUpdateData (instead of contentUpdateData)
Translating - contentUpdateData (standard across all contents)

Dawid says we should use contentTranslateData system-wise but we have not been using it at all anywhere. Could you please share your point of view on this?

} else {
$formBuilder->addModelTransformer($this->getModelTransformer());
}
$formBuilder->addModelTransformer($this->getModelTransformer());

$formBuilder->setAutoInitialize(false);

Expand Down