Can you just do that with a $isCacheEnabled = !$isPreviewMode && $this->container->getParameter('presta_cms_core.cache.enabled')