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

Add compatibility with Prestashop 8.0.0 on demomultistoreform module #112

Merged
merged 1 commit into from
Oct 19, 2022
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
18 changes: 18 additions & 0 deletions demomultistoreform/src/Form/ContentBlockDataConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, string>
*/
private const CONFIGURATION_FIELDS = ['color', 'italic', 'bold'];

/**
* {@inheritdoc}
Expand Down Expand Up @@ -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;
}


}
10 changes: 6 additions & 4 deletions demomultistoreform/views/templates/admin/form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<div class="alert alert-info" role="alert">
Expand All @@ -34,8 +36,8 @@
<h3 class="card-header">
<i class="material-icons">business_center</i> Content block
</h3>
<div class="card-block row">
<div class="card-text">
<div class="card-body card-block">
<div class="form-wrapper card-text">
{{ form_widget(contentBlockForm) }}
</div>
</div>
Expand Down
12 changes: 7 additions & 5 deletions demomultistoreform/views/templates/admin/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
} %}
{% endif %}

{% extends '@PrestaShop/Admin/layout.html.twig' %}
{% form_theme configurationForm '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 configurationForm '@PrestaShop/Admin/TwigTemplateForm/prestashop_ui_kit.html.twig' %}


{% block content %}
Expand All @@ -51,8 +53,8 @@
<h3 class="card-header">
<i class="material-icons">business_center</i> Content blocks configuration
</h3>
<div class="card-block row">
<div class="card-text">
<div class="card-body card-block">
<div class="form-wrapper card-text">
{{ form_widget(configurationForm) }}
{{ form_rest(configurationForm) }}
</div>
Expand All @@ -68,6 +70,6 @@
{% endblock %}

{% block javascripts %}
{{ parent() }}
{{ parent() }}
<script src="{{ asset('../modules/demomultistoreform/views/js/form.js') }}"></script>
{% endblock %}