Initial Commit
This commit is contained in:
88
local/modules/SliderRevolution/Hook/BackHookManager.php
Normal file
88
local/modules/SliderRevolution/Hook/BackHookManager.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Copyright (c) Franck Allimant, CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
/**
|
||||
* Created by Franck Allimant, CQFDev <franck@cqfdev.fr>
|
||||
* Date: 05/03/2016 18:11
|
||||
*/
|
||||
|
||||
namespace SliderRevolution\Hook;
|
||||
|
||||
use SliderRevolution\Model\SliderAssociationQuery;
|
||||
use SliderRevolution\SliderRevolution;
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
use Thelia\Model\ModuleConfig;
|
||||
use Thelia\Model\ModuleConfigQuery;
|
||||
|
||||
class BackHookManager extends BaseHook
|
||||
{
|
||||
public function onModuleConfigure(HookRenderEvent $event)
|
||||
{
|
||||
$vars = [];
|
||||
|
||||
if (null !== $params = ModuleConfigQuery::create()->findByModuleId(SliderRevolution::getModuleId())) {
|
||||
/** @var ModuleConfig $param */
|
||||
foreach ($params as $param) {
|
||||
$vars[ $param->getName() ] = $param->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
$event->add(
|
||||
$this->render('sliderrevolution/module-configuration.html', $vars)
|
||||
);
|
||||
}
|
||||
|
||||
public function onCategoryEditRightColumnBottom(HookRenderEvent $event)
|
||||
{
|
||||
return $this->renderSliderAssocSelector($event, 'category', $event->getArgument('category_id'));
|
||||
}
|
||||
|
||||
public function onContentEditRightColumnBottom(HookRenderEvent $event)
|
||||
{
|
||||
return $this->renderSliderAssocSelector($event, 'content', $event->getArgument('content_id'));
|
||||
}
|
||||
|
||||
public function onFolderEditRightColumnBottom(HookRenderEvent $event)
|
||||
{
|
||||
return $this->renderSliderAssocSelector($event, 'folder', $event->getArgument('folder_id'));
|
||||
}
|
||||
|
||||
public function onBrandEditRightColumnBottom(HookRenderEvent $event)
|
||||
{
|
||||
return $this->renderSliderAssocSelector($event, 'brand', $event->getArgument('brand_id'));
|
||||
}
|
||||
|
||||
public function onProductEditRightColumnBottom(HookRenderEvent $event)
|
||||
{
|
||||
return $this->renderSliderAssocSelector($event, 'product', $event->getArgument('product_id'));
|
||||
}
|
||||
|
||||
protected function renderSliderAssocSelector(HookRenderEvent $event, $objectType, $objectId)
|
||||
{
|
||||
if (null !== $sliderAssoc = SliderAssociationQuery::create()
|
||||
->filterByObjectType($objectType)
|
||||
->filterByObjectId($objectId)
|
||||
->findOne()) {
|
||||
$sliderAlias = $sliderAssoc->getSliderAlias();
|
||||
} else {
|
||||
$sliderAlias = '';
|
||||
}
|
||||
|
||||
$event->add(
|
||||
$this->render(
|
||||
"sliderrevolution/slider-selector.html",
|
||||
[
|
||||
'slider_alias' => $sliderAlias
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user