From 39a1226f7f12e2a379006ee5b2fbda9fe01e3d23 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Thu, 9 Feb 2023 15:58:01 +0100 Subject: [PATCH 1/2] IBX-4486: Disabled Autosave feature for `nodraft` requests (#66) * IBX-4486: Disabled Autosave feature for `nodraft` requests * IBX-4486: Removed unnecessary ternary operator * IBX-4486: Changed option to `autosave_enabled` --- .../View/Filter/ContentCreateViewFilter.php | 7 ++- src/lib/Form/Type/Content/ContentEditType.php | 45 +++++++++++-------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/lib/Content/View/Filter/ContentCreateViewFilter.php b/src/lib/Content/View/Filter/ContentCreateViewFilter.php index c2370069..99b2c94f 100644 --- a/src/lib/Content/View/Filter/ContentCreateViewFilter.php +++ b/src/lib/Content/View/Filter/ContentCreateViewFilter.php @@ -86,7 +86,8 @@ public function handleContentCreateForm(FilterViewBuilderParametersEvent $event) $contentCreateData = $this->resolveContentCreateData($contentType, $location, $languageCode); $form = $this->resolveContentCreateForm( $contentCreateData, - $languageCode + $languageCode, + false ); $event->getParameters()->add(['form' => $form->handleRequest($request)]); @@ -123,13 +124,15 @@ private function resolveContentCreateData( */ private function resolveContentCreateForm( ContentCreateData $contentCreateData, - string $languageCode + string $languageCode, + bool $autosaveEnabled = true ): FormInterface { return $this->formFactory->create(ContentEditType::class, $contentCreateData, [ 'languageCode' => $languageCode, 'mainLanguageCode' => $languageCode, 'contentCreateStruct' => $contentCreateData, 'drafts_enabled' => true, + 'autosave_enabled' => $autosaveEnabled, ]); } } diff --git a/src/lib/Form/Type/Content/ContentEditType.php b/src/lib/Form/Type/Content/ContentEditType.php index a5950cf9..5431e5f3 100644 --- a/src/lib/Form/Type/Content/ContentEditType.php +++ b/src/lib/Form/Type/Content/ContentEditType.php @@ -43,26 +43,32 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder ->add('publish', SubmitType::class, ['label' => 'Publish']); - if ($options['drafts_enabled']) { - $builder - ->add('saveDraft', SubmitType::class, [ - 'label' => /** @Desc("Save draft") */ 'save_draft', - 'attr' => ['formnovalidate' => 'formnovalidate'], - ]) - ->add('cancel', SubmitType::class, [ - 'label' => /** @Desc("Cancel") */ 'cancel', - 'attr' => ['formnovalidate' => 'formnovalidate'], - ]) - ->add('autosave', SubmitType::class, [ - 'label' => /** @Desc("Autosave") */ 'autosave', - 'attr' => [ - 'hidden' => true, - 'formnovalidate' => 'formnovalidate', - ], - 'translation_domain' => 'content_edit', - ]); - $builder->addEventSubscriber(new SuppressValidationSubscriber()); + if (!$options['drafts_enabled']) { + return; } + + $builder + ->add('saveDraft', SubmitType::class, [ + 'label' => /** @Desc("Save draft") */ 'save_draft', + 'attr' => ['formnovalidate' => 'formnovalidate'], + ]) + ->add('cancel', SubmitType::class, [ + 'label' => /** @Desc("Cancel") */ 'cancel', + 'attr' => ['formnovalidate' => 'formnovalidate'], + ]); + + if ($options['autosave_enabled']) { + $builder->add('autosave', SubmitType::class, [ + 'label' => /** @Desc("Autosave") */ 'autosave', + 'attr' => [ + 'hidden' => true, + 'formnovalidate' => 'formnovalidate', + ], + 'translation_domain' => 'content_edit', + ]); + } + + $builder->addEventSubscriber(new SuppressValidationSubscriber()); } public function configureOptions(OptionsResolver $resolver) @@ -73,6 +79,7 @@ public function configureOptions(OptionsResolver $resolver) 'contentCreateStruct' => null, 'contentUpdateStruct' => null, 'drafts_enabled' => false, + 'autosave_enabled' => true, 'data_class' => ContentStruct::class, 'translation_domain' => 'ezplatform_content_forms_content', 'intent' => 'update', From 7dc9e9068b2980244ef46fbd2bce8cdf984fe75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Parafi=C5=84ski?= Date: Fri, 10 Feb 2023 08:43:16 +0100 Subject: [PATCH 2/2] [Composer] Disabled all plugins by default (#67) --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index cc5df431..f8fa3e24 100644 --- a/composer.json +++ b/composer.json @@ -55,6 +55,11 @@ "dev-master": "1.3.x-dev" } }, + "config": { + "allow-plugins": { + "*/*": false + } + }, "scripts": { "fix-cs": "php-cs-fixer fix -v --show-progress=estimating", "check-cs": "@fix-cs --dry-run",