-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from Oksydan/develop
Release new version 2.3.0
- Loading branch information
Showing
7 changed files
with
114 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Oksydan\IsImageslider\Hook; | ||
|
||
class WidgetCapability extends AbstractCacheableDisplayHook | ||
{ | ||
private const TEMPLATE_FILE = 'slider.tpl'; | ||
|
||
protected function getTemplate(): string | ||
{ | ||
return WidgetCapability::TEMPLATE_FILE; | ||
} | ||
|
||
protected function getCacheKey(): string | ||
{ | ||
return parent::getCacheKey() . '_' . ($this->context->isMobile() ? 'mobile' : 'desktop'); | ||
} | ||
|
||
/** | ||
* @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; | ||
} | ||
|
||
public function getWidgetVariables($params): array | ||
{ | ||
return [ | ||
'homeslider' => [ | ||
'slides' => $this->getSlides(), | ||
'speed' => $this->sliderConfiguration->getSliderSpeed(), | ||
'pause' => $this->sliderConfiguration->getSliderPauseOnHover(), | ||
'wrap' => $this->sliderConfiguration->getSliderWrap(), | ||
], | ||
]; | ||
} | ||
|
||
protected function assignTemplateVariables(array $params) | ||
{ | ||
$this->context->smarty->assign($this->getWidgetVariables($params)); | ||
} | ||
|
||
public function renderWidget($params): string | ||
{ | ||
return $this->execute($params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters