proxyCacheEnabled = findModule(\Modules::PROXY_CACHE, 'home'); } /** * @return $this * * @required */ public function setLanguageContext(LanguageContext $languageContext) { $this->languageContext = $languageContext; return $this; } /** * @return $this * * @required */ public function setCurrencyContext(CurrencyContext $currencyContext) { $this->currencyContext = $currencyContext; return $this; } /** * @required */ public function setHomePage(HomePage $homePage): void { $this->homePage = $homePage; } public function getHeaderVariables() { $dbcfg = \Settings::getDefault(); $header = parent::getHeaderVariables(); $header['pageTitle'] = $dbcfg['index_title']; $header['meta_keywords'] = $dbcfg['index_keywords']; $header['meta_description'] = $dbcfg['index_description']; return $header; } public function getBodyVariables() { $vars = parent::getBodyVariables(); $this->homePage->setView($this); try { $page = $this->homePage->getPage(); } catch (PageException $e) { $page = false; } $vars['html_page'] = $page['block'] ?? null; $vars['productsList'] = []; $vars['page'] = $page; return $vars; } public function getResponse(?Request $request = null) { if (findModule(\Modules::RESPONSE_CACHE, 'home') && !isFunctionalTests() && !getAdminUser() && $this->request->get('skip_gtm') === null ) { $cacheContext = Contexts::get(CacheContext::class); $cacheKeyContext = $cacheContext->getKey([CacheContext::TYPE_FULL_PAGE, CacheContext::TYPE_PRICE, CacheContext::TYPE_TEXT]); $isHit = false; if (!is_null($cacheKeyContext)) { $responseCache = ServiceContainer::getService(ResponseCache::class); $this->responseCacheEnabled = true; $cacheKey = ['home']; $cacheKey[] = $cacheKeyContext; $cacheKey[] = 'rc'; $cacheKey = join('-', $cacheKey); $response = $responseCache->wrap(function () use ($request) { return parent::getResponse($request); }, $cacheKey, 15 * 60, null, $isHit); } $metrics = ServiceContainer::getService(PrometheusWrapper::class); $metrics->setCounter('kupshop', 'home_cache_used', '', 1, ['used' => $isHit ? '1' : '0']); } if (!isset($response)) { $response = parent::getResponse($request); } return $response; } public function getWpjToolbar() { $arr = [ 'url' => getAdminUrl('PagesSystem', ['pageType' => 'HOME']), 'title' => 'Upravit stránku', ]; return array_merge(parent::getWpjToolbar(), $arr); } }