feat(main): Groups and blocks
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user