feat(main): Add slider block type
This commit is contained in:
@@ -3,8 +3,10 @@
|
||||
namespace Websmid\CustomHtml\Form\DataProvider;
|
||||
|
||||
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\FormDataProviderInterface;
|
||||
use Websmid\CustomHtml\Config\Config;
|
||||
use Websmid\CustomHtml\Model\CustomHtmlBlock;
|
||||
use Websmid\CustomHtml\Model\CustomHtmlFaq;
|
||||
use Websmid\CustomHtml\Model\CustomHtmlSlide;
|
||||
use Validate;
|
||||
|
||||
final class CustomHtmlBlockDataProvider implements FormDataProviderInterface
|
||||
@@ -28,9 +30,16 @@ final class CustomHtmlBlockDataProvider implements FormDataProviderInterface
|
||||
'description' => $block->description,
|
||||
'extra_description' => $block->extra_description,
|
||||
'link' => $block->link,
|
||||
'link_text' => $block->link_text,
|
||||
'alert_type' => $block->alert_type,
|
||||
'timeout' => (int) $block->timeout,
|
||||
'slider_mode' => $block->slider_mode,
|
||||
'slides_per_view_mobile' => (float) $block->slides_per_view_mobile,
|
||||
'slides_per_view_tablet' => (float) $block->slides_per_view_tablet,
|
||||
'slides_per_view_desktop' => (float) $block->slides_per_view_desktop,
|
||||
'autoplay_delay' => (int) $block->autoplay_delay,
|
||||
'faqs' => $this->loadFaqs((int) $id),
|
||||
'slides' => $this->loadSlides((int) $id),
|
||||
'active' => (bool) $block->active,
|
||||
];
|
||||
}
|
||||
@@ -48,9 +57,16 @@ final class CustomHtmlBlockDataProvider implements FormDataProviderInterface
|
||||
'description' => '',
|
||||
'extra_description' => '',
|
||||
'link' => '',
|
||||
'link_text' => '',
|
||||
'alert_type' => 'info',
|
||||
'timeout' => 0,
|
||||
'slider_mode' => Config::SLIDER_DEFAULT_MODE,
|
||||
'slides_per_view_mobile' => Config::SLIDER_DEFAULT_SLIDES_PER_VIEW_MOBILE,
|
||||
'slides_per_view_tablet' => Config::SLIDER_DEFAULT_SLIDES_PER_VIEW_TABLET,
|
||||
'slides_per_view_desktop' => Config::SLIDER_DEFAULT_SLIDES_PER_VIEW_DESKTOP,
|
||||
'autoplay_delay' => 0,
|
||||
'faqs' => [],
|
||||
'slides' => [],
|
||||
'active' => true,
|
||||
];
|
||||
}
|
||||
@@ -64,4 +80,19 @@ final class CustomHtmlBlockDataProvider implements FormDataProviderInterface
|
||||
];
|
||||
}, CustomHtmlFaq::getByBlockId($idBlock));
|
||||
}
|
||||
|
||||
private function loadSlides(int $idBlock): array
|
||||
{
|
||||
return array_map(static function (array $slide) {
|
||||
return [
|
||||
'id' => (int) $slide['id_ws_customhtml_slide'],
|
||||
'title' => $slide['title'],
|
||||
'description' => $slide['description'],
|
||||
'extra_description' => $slide['extra_description'],
|
||||
'link' => $slide['link'],
|
||||
'link_text' => $slide['link_text'],
|
||||
'image' => null,
|
||||
];
|
||||
}, CustomHtmlSlide::getByBlockId($idBlock));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user