From 7ae7553defd8aaa58f0a081f5fc8cc1cfd78db67 Mon Sep 17 00:00:00 2001 From: Maxime Flasquin Date: Wed, 12 Oct 2022 16:26:07 +0200 Subject: [PATCH] Add compatibility with Prestashop 8.0.0 on demomultistoreform module --- .../src/Form/ContentBlockDataConfiguration.php | 18 ++++++++++++++++++ .../views/templates/admin/form.html.twig | 10 ++++++---- .../views/templates/admin/index.html.twig | 12 +++++++----- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/demomultistoreform/src/Form/ContentBlockDataConfiguration.php b/demomultistoreform/src/Form/ContentBlockDataConfiguration.php index 3a83a1c6..8465cec6 100644 --- a/demomultistoreform/src/Form/ContentBlockDataConfiguration.php +++ b/demomultistoreform/src/Form/ContentBlockDataConfiguration.php @@ -22,12 +22,17 @@ namespace PrestaShop\Module\DemoMultistoreForm\Form; use PrestaShop\PrestaShop\Core\Configuration\AbstractMultistoreConfiguration; +use Symfony\Component\OptionsResolver\OptionsResolver; /** * Handles configuration data for demo multistore configuration options. */ final class ContentBlockDataConfiguration extends AbstractMultistoreConfiguration { + /** + * @var array + */ + private const CONFIGURATION_FIELDS = ['color', 'italic', 'bold']; /** * {@inheritdoc} @@ -66,4 +71,17 @@ public function validateConfiguration(array $configuration): bool { return true; } + + protected function buildResolver(): OptionsResolver + { + $resolver = new OptionsResolver(); + $resolver->setDefined(self::CONFIGURATION_FIELDS); + $resolver->setAllowedTypes('color', 'string'); + $resolver->setAllowedTypes('italic', 'bool'); + $resolver->setAllowedTypes('bold', 'bool'); + + return $resolver; + } + + } diff --git a/demomultistoreform/views/templates/admin/form.html.twig b/demomultistoreform/views/templates/admin/form.html.twig index 484c97ec..5c39782f 100644 --- a/demomultistoreform/views/templates/admin/form.html.twig +++ b/demomultistoreform/views/templates/admin/form.html.twig @@ -17,8 +17,10 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) #} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% form_theme contentBlockForm 'PrestaShopBundle:Admin/TwigTemplateForm:prestashop_ui_kit.html.twig' %} +{% extends '@!PrestaShop/Admin/layout.html.twig' %} +{# Since PS 8.0.0 you can use @PrestaShopCore instead of @!Prestashop +(https://devdocs.prestashop-project.org/8/modules/concepts/templating/admin-views/#override-templates) #} +{% form_theme contentBlockForm '@PrestaShop/Admin/TwigTemplateForm/prestashop_ui_kit.html.twig' %} {% block content %}