Skip to content
Merged
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
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ parameters:
count: 4
path: src/bundle/Controller/UserRegisterController.php

-
message: '#^Call to an undefined method Symfony\\Component\\Form\\FormInterface\:\:getClickedButton\(\)\.$#'
identifier: method.notFound
count: 2
path: src/bundle/Controller/UserSettingsController.php

-
message: '#^Cannot call method getAPIUser\(\) on Symfony\\Component\\Security\\Core\\User\\UserInterface\|null\.$#'
identifier: method.nonObject
Expand Down
12 changes: 1 addition & 11 deletions src/bundle/Controller/UserSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
use Ibexa\User\Form\Data\UserSettingUpdateData;
use Ibexa\User\Form\Factory\FormFactory;
use Ibexa\User\Form\SubmitHandler;
use Ibexa\User\Form\Type\UserSettingUpdateType;
use Ibexa\User\UserSetting\UserSettingService;
use Ibexa\User\UserSetting\ValueDefinitionRegistry;
use Ibexa\User\View\UserSettings\ListView;
use Ibexa\User\View\UserSettings\UpdateView;
use JMS\TranslationBundle\Annotation\Desc;
use Symfony\Component\Form\Button;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -71,7 +69,7 @@ public function updateAction(Request $request, UpdateView $view): Response|Updat
$form->handleRequest($request);

if ($form->isSubmitted()) {
$result = $this->submitHandler->handle($form, function (UserSettingUpdateData $data) use ($form): RedirectResponse {
$result = $this->submitHandler->handle($form, function (UserSettingUpdateData $data): RedirectResponse {
foreach ($data->getValues() as $identifier => $value) {
$this->userSettingService->setUserSetting($identifier, (string)$value['value']);
}
Expand All @@ -83,14 +81,6 @@ public function updateAction(Request $request, UpdateView $view): Response|Updat
'ibexa_user_settings'
);

if ($form->getClickedButton() instanceof Button
&& $form->getClickedButton()->getName() === UserSettingUpdateType::BTN_UPDATE_AND_EDIT
) {
return $this->redirectToRoute('ibexa.user_settings.update', [
'identifier' => $data->getIdentifier(),
]);
}

return new RedirectResponse($this->generateUrl('ibexa.user_settings.list'));
});

Expand Down
7 changes: 2 additions & 5 deletions src/lib/Form/Type/UserSettingUpdateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

class UserSettingUpdateType extends AbstractType
{
public const string BTN_UPDATE_AND_EDIT = 'update_and_edit';

public function __construct(
protected FormMapperRegistry $formMapperRegistry,
protected ValueDefinitionRegistry $valueDefinitionRegistry
Expand All @@ -38,7 +36,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
);

$builder
->add('identifier', HiddenType::class, []);
->add('identifier', HiddenType::class);

foreach ($groupDefinition->getValueDefinitions() as $identifier => $valueDefinition) {
$formMapper = $this->formMapperRegistry->getFormMapper($identifier);
Expand All @@ -55,8 +53,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void

$builder->add($sub);
}
$builder->add('update', SubmitType::class, []);
$builder->add(self::BTN_UPDATE_AND_EDIT, SubmitType::class);
$builder->add('update', SubmitType::class);
}

public function configureOptions(OptionsResolver $resolver): void
Expand Down
Loading