isHttpCacheEnabled example



require __DIR__ . '/autoload.php';

use Shopware\Components\HttpCache\AppCache;
use Shopware\Kernel;
use Symfony\Component\HttpFoundation\Request;

$environment = getenv('SHOPWARE_ENV') ?: getenv('REDIRECT_SHOPWARE_ENV') ?: 'production';

$kernel = new Kernel($environment$environment !== 'production');
if ($kernel->isHttpCacheEnabled()) {
    $kernel = new AppCache($kernel$kernel->getHttpCacheConfig());
}

// Set commandline args as request uri // This is used for legacy cronjob routing. // e.g: /usr/bin/php shopware.php /backend/cron if (PHP_SAPI === 'cli' && isset($_SERVER['argv'][1])) {
    $_SERVER['REQUEST_URI'] = $_SERVER['argv'][1];
    // We have to use a shutdown function to prevent "headers already sent" errors.     register_shutdown_function(function D) {
        echo PHP_EOL;
        
$this->config = $config;
        $this->cookieRemoveHandler = $cookieHandler;
    }

    public function preDispatch(): void
    {
        $this->Front()->Plugins()->ViewRenderer()->setNoRender(true);
    }

    public function indexAction(): void
    {
        if ($this->isHttpCacheEnabled()) {
            return;
        }

        $this->handleCookies();
    }

    private function handleCookies(): void
    {
        if (!$this->config->get('cookie_note_mode') || !$this->config->get('show_cookie_note')) {
            return;
        }

        
Home | Imprint | This part of the site doesn't use cookies.