35 lines
831 B
PHP
35 lines
831 B
PHP
<?php
|
|
|
|
namespace Websmid\CustomHtml\Form\DataProvider;
|
|
|
|
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\FormDataProviderInterface;
|
|
use Websmid\CustomHtml\Model\CustomHtmlGroup;
|
|
use Validate;
|
|
|
|
final class CustomHtmlGroupDataProvider implements FormDataProviderInterface
|
|
{
|
|
public function getData($id)
|
|
{
|
|
$group = new CustomHtmlGroup((int) $id);
|
|
|
|
if (!Validate::isLoadedObject($group)) {
|
|
return $this->getDefaultData();
|
|
}
|
|
|
|
return [
|
|
'title' => $group->title,
|
|
'hook_name' => $group->hook_name,
|
|
'active' => (bool) $group->active,
|
|
];
|
|
}
|
|
|
|
public function getDefaultData()
|
|
{
|
|
return [
|
|
'title' => '',
|
|
'hook_name' => '',
|
|
'active' => true,
|
|
];
|
|
}
|
|
}
|