getDefaultData();
}
return [
'id_ws_customhtml_group' => (int) $block->id_ws_customhtml_group,
'title' => $block->title,
'type' => $block->type,
'show_title' => (bool) $block->show_title,
'custom_class' => $block->custom_class,
'content' => $block->content,
'image' => null,
'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 > 0 ? (float) $block->slides_per_view_desktop : null,
'autoplay_delay' => (int) $block->autoplay_delay,
'faqs' => $this->loadFaqs((int) $id),
'slides' => $this->loadSlides((int) $id),
'active' => (bool) $block->active,
];
}
public function getDefaultData()
{
return [
'id_ws_customhtml_group' => 0,
'title' => '',
'type' => 'html',
'show_title' => false,
'custom_class' => '',
'content' => '',
'image' => null,
'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' => null,
'autoplay_delay' => 0,
'faqs' => [],
'slides' => [],
'active' => true,
];
}
private function loadFaqs(int $idBlock): array
{
return array_map(static function (array $faq) {
return [
'question' => $faq['question'],
'answer' => $faq['answer'],
];
}, 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));
}
}