diff --git a/src/Sylius/Bundle/CoreBundle/Form/Extension/DisabledCsrfProtectionFormExtension.php b/src/Sylius/Bundle/CoreBundle/Form/Extension/DisabledCsrfProtectionFormExtension.php new file mode 100644 index 0000000000..af84ebc4c0 --- /dev/null +++ b/src/Sylius/Bundle/CoreBundle/Form/Extension/DisabledCsrfProtectionFormExtension.php @@ -0,0 +1,43 @@ +container->hasParameter('form.type_extension.csrf.enabled') + ? $this->container->getParameter('form.type_extension.csrf.enabled') + : true; + + if (!$csrfEnabled) { + $resolver->setDefault('csrf_protection', false); + } + } +} diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/services/form.php b/src/Sylius/Bundle/CoreBundle/Resources/config/services/form.php index 71aac23b42..7bb960bc53 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/services/form.php +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/services/form.php @@ -26,6 +26,7 @@ use Sylius\Bundle\CoreBundle\Form\Extension\CartItemTypeExtension; use Sylius\Bundle\CoreBundle\Form\Extension\CartTypeExtension; use Sylius\Bundle\CoreBundle\Form\Extension\CatalogPromotionTypeExtension; use Sylius\Bundle\CoreBundle\Form\Extension\ChannelTypeExtension; +use Sylius\Bundle\CoreBundle\Form\Extension\DisabledCsrfProtectionFormExtension; use Sylius\Bundle\CoreBundle\Form\Extension\OrderTypeExtension; use Sylius\Bundle\CoreBundle\Form\Extension\PaymentMethodTypeExtension; use Sylius\Bundle\CoreBundle\Form\Extension\ProductTranslationTypeExtension; @@ -181,6 +182,12 @@ return static function (ContainerConfigurator $container) { ->tag('form.type_extension', ['priority' => 100]) ; + $services + ->set('sylius.form.extension.type.disabled_csrf_protection', DisabledCsrfProtectionFormExtension::class) + ->args([service('service_container')]) + ->tag('form.type_extension', ['priority' => 100]) + ; + $services ->set('sylius.form.type.product_review', ProductReviewType::class) ->args([