feat(main): Groups and blocks

This commit is contained in:
2026-08-10 16:13:15 +02:00
parent 6aff506cd6
commit 635c13a0ed
39 changed files with 1188 additions and 237 deletions
@@ -0,0 +1,44 @@
<?php
namespace Websmid\CustomHtml\Form\DataHandler;
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\FormDataHandlerInterface;
use Websmid\CustomHtml\Model\CustomHtmlBlock;
use Validate;
final class CustomHtmlBlockDataHandler implements FormDataHandlerInterface
{
public function create(array $formData)
{
$block = new CustomHtmlBlock();
$block->id_ws_customhtml_group = (int) $formData['id_ws_customhtml_group'];
$block->title = (string) $formData['title'];
$block->show_title = (int) $formData['show_title'];
$block->content = (string) $formData['content'];
$block->active = (int) $formData['active'];
$block->ordering = 0;
if (!$block->add()) {
return false;
}
return $block->id;
}
public function update($id, array $formData)
{
$block = new CustomHtmlBlock((int) $id);
if (!Validate::isLoadedObject($block)) {
return false;
}
$block->id_ws_customhtml_group = (int) $formData['id_ws_customhtml_group'];
$block->title = (string) $formData['title'];
$block->show_title = (int) $formData['show_title'];
$block->content = (string) $formData['content'];
$block->active = (int) $formData['active'];
return (bool) $block->update();
}
}