Initial commit: is_imageslider out of the box. v2.3.2
This commit is contained in:
53
is_imageslider/src/Hook/DisplayHome.php
Normal file
53
is_imageslider/src/Hook/DisplayHome.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Oksydan\IsImageslider\Hook;
|
||||
|
||||
class DisplayHome extends AbstractCacheableDisplayHook
|
||||
{
|
||||
private const TEMPLATE_FILE = 'slider.tpl';
|
||||
|
||||
protected function getTemplate(): string
|
||||
{
|
||||
return DisplayHome::TEMPLATE_FILE;
|
||||
}
|
||||
|
||||
protected function assignTemplateVariables(array $params)
|
||||
{
|
||||
$this->context->smarty->assign([
|
||||
'homeslider' => [
|
||||
'slides' => $this->getSlides(),
|
||||
'speed' => $this->sliderConfiguration->getSliderSpeed(),
|
||||
'pause' => $this->sliderConfiguration->getSliderPauseOnHover(),
|
||||
'wrap' => $this->sliderConfiguration->getSliderWrap(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getSlides(): array
|
||||
{
|
||||
$now = new \DateTime();
|
||||
$slides = $this->slideRepository->getActiveSliderByLandAndStoreId(
|
||||
$this->context->language->id,
|
||||
$this->context->shop->id,
|
||||
true,
|
||||
0, // 0 means no limit
|
||||
$now
|
||||
);
|
||||
|
||||
foreach ($slides as &$slide) {
|
||||
$slide = $this->slidePresenter->present($slide);
|
||||
}
|
||||
|
||||
return $slides;
|
||||
}
|
||||
|
||||
protected function getCacheKey(): string
|
||||
{
|
||||
return parent::getCacheKey() . '_' . ($this->context->isMobile() ? 'mobile' : 'desktop');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user