feat(main): conform to Websmid module standards
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Websmid\CustomHtml\Module;
|
||||
|
||||
use Websmid\CustomHtml\Model\CustomHtml;
|
||||
use Context;
|
||||
|
||||
trait DisplayHooks
|
||||
{
|
||||
public function renderWidget($hookName = null, array $configuration = [])
|
||||
{
|
||||
if (empty($hookName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$idLang = (int) Context::getContext()->language->id;
|
||||
$templateFile = 'module:ws_customhtml/views/templates/hook/customhtml_block.tpl';
|
||||
$cacheId = $this->getCacheId('ws_customhtml_' . $idLang . '_' . $hookName);
|
||||
|
||||
if (!$this->isCached($templateFile, $cacheId)) {
|
||||
$variables = $this->getWidgetVariables($hookName, $configuration);
|
||||
|
||||
if (empty($variables)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->smarty->assign($variables);
|
||||
}
|
||||
|
||||
return $this->fetch($templateFile, $cacheId);
|
||||
}
|
||||
|
||||
public function getWidgetVariables($hookName = null, array $configuration = [])
|
||||
{
|
||||
$blockList = CustomHtml::getActiveByHookName((string) $hookName);
|
||||
|
||||
if (empty($blockList)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'hookName' => $hookName,
|
||||
'blockList' => $blockList,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user