/** * Sets the shopware cache headers */ public function setCacheHeaders() { $controllerName = strtolower($this->request->getModuleName()) . '/' . strtolower($this->request->getControllerName()); $cacheControllers = $this->getCacheControllers(); if (!isset($cacheControllers[$controllerName])) { return false; } if (strpos($this->request->getPathInfo(), '/widgets/index/refreshStatistic') !== false) { return false; } if (strpos($this->request->getPathInfo(), '/captcha/index/rand/') !== false) { return false; } $allowNoCache = $this->getNoCacheTagsForController($controllerName); $noCacheCookies = $this->getNoCacheTagsFromCookie($this->request); $hasMatchingNoCacheCookie = $this->hasArrayIntersection($allowNoCache, $noCacheCookies); // Enable esi tag output $this->registerEsiRenderer(); if ($this->response->isRedirect()) { $this->response->setHeader('Cache-Control', 'private, no-cache'); return false; } if ($hasMatchingNoCacheCookie) { $this->response->setHeader('Cache-Control', 'private, no-cache'); return false; } $allowNoCacheControllers = $this->getAllowNoCacheControllers(); if (isset($allowNoCacheControllers[$controllerName]) && $this->request->getQuery('nocache') !== null) { $this->response->setHeader('Cache-Control', 'private, no-cache'); return false; } // NEVER cache a filled mini-basket if ($controllerName == 'widgets/checkout' && !empty(Shopware()->Session()->sBasketQuantity)) { $this->response->setHeader('Cache-Control', 'private, no-cache'); return false; } $cacheTime = (int) $cacheControllers[$controllerName]; $this->request->setParam('__cache', $cacheTime); $this->response->setHeader('Cache-Control', 'public, max-age=' . $cacheTime . ', s-maxage=' . $cacheTime, true); if (!empty($allowNoCache)) { $this->response->setHeader('x-shopware-allow-nocache', implode(', ', $allowNoCache)); } return true; }
/** * @param Enlight_Controller_Request_RequestHttp $request */ protected function fixRequest($request) { $aliases = array('sViewport' => 'controller', 'sAction' => 'action'); foreach ($aliases as $key => $alias) { if (($value = $request->getParam($key)) !== null) { $request->setParam($alias, $value); $request->setAlias($key, $alias); } } $request->setQuery($request->getUserParams() + $request->getQuery()); }
/** * Returns an array with all current values in _GET * * @return array */ public function toArray() { return $this->request->getQuery(); }
/** * Sets the shopware cache headers */ public function setCacheHeaders() { $controllerName = $this->request->getModuleName() . '/' . $this->request->getControllerName(); if(isset($this->cacheControllers[$controllerName])) { // Enable esi tag output $this->registerEsiRenderer(); } if ((isset($this->allowNoCacheControllers[$controllerName]) && $this->request->getQuery('nocache') !== null) || $this->response->isRedirect() || (!$this->request->getParam('rewriteUrl') && isset($this->controllerOptions[$controllerName])) ) { $this->response->setHeader('Cache-Control', 'private, no-cache'); } elseif (isset($this->cacheControllers[$controllerName])) { $cacheTime = (int)$this->cacheControllers[$controllerName]; $this->request->setParam('__cache', $cacheTime); $this->response->setHeader('Cache-Control', 'public, max-age=' . $cacheTime . ', s-maxage=' . $cacheTime); } $shopId = Shopware()->Shop()->getId(); $allowNoCache = array(); if(!empty($this->Config()->admin)) { $allowNoCache[] = 'admin-' . $shopId; } if (isset($this->allowNoCacheControllers[$controllerName])) { $allowNoCache[] = $this->allowNoCacheControllers[$controllerName] . '-' . $shopId; } if(!empty($allowNoCache)) { $this->response->setHeader('x-shopware-allow-nocache', implode(', ', $allowNoCache)); } }
/** * @param Symfony\Component\HttpFoundation\Request $request * @return \Enlight_Controller_Request_RequestHttp */ public function createRequest(Request $request) { $request->overrideGlobals(); $request = new ControllerRequest( str_replace(" ","+",$request->getUri()) ); $request->setQuery($request->getQuery()); return $request; }
/** * Replaces the query params with their mathing long form * * @param \Enlight_Controller_Request_RequestHttp $request */ public function replaceShortRequestQueries(\Enlight_Controller_Request_RequestHttp $request) { foreach ($this->getQueryAliases() as $key => $alias) { $value = $request->getQuery($alias); if ($value !== null) { $request->setQuery($key, $value); $request->setQuery($alias, null); } } }
public function setBaseInfo(\Enlight_Controller_Request_RequestHttp $request) { $this->data['controller'] = $request->getControllerName(); $this->data['getData'] = $request->getQuery(); $this->data['postData'] = $request->getPost(); }