41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
use Bitrix\Main\Application;
|
|
use Jinove\Vinoteca\Catalog\MegaMenu;
|
|
|
|
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
|
|
die();
|
|
}
|
|
|
|
class JinoveCatalogMegaMenuComponent extends CBitrixComponent
|
|
{
|
|
public function onPrepareComponentParams($params): array
|
|
{
|
|
$params["IBLOCK_ID"] = (int)($params["IBLOCK_ID"] ?? 0);
|
|
$params["BRANDS_LIMIT"] = max(1, (int)($params["BRANDS_LIMIT"] ?? 10));
|
|
$params["CACHE_TIME"] = (int)($params["CACHE_TIME"] ?? 86400);
|
|
|
|
return $params;
|
|
}
|
|
|
|
public function executeComponent(): void
|
|
{
|
|
if ($this->arParams["IBLOCK_ID"] <= 0) {
|
|
return;
|
|
}
|
|
if ($this->startResultCache()) {
|
|
$this->arResult = MegaMenu::collect($this->arParams["IBLOCK_ID"], $this->arParams["BRANDS_LIMIT"]);
|
|
$taggedCache = Application::getInstance()->getTaggedCache();
|
|
foreach (MegaMenu::tags($this->arParams["IBLOCK_ID"]) as $tag) {
|
|
$taggedCache->registerTag($tag);
|
|
}
|
|
if (empty($this->arResult["TYPES"])) {
|
|
$this->abortResultCache();
|
|
|
|
return;
|
|
}
|
|
$this->includeComponentTemplate();
|
|
}
|
|
}
|
|
}
|