Example #1
0
 /**
  * Clears a given cache info item. This method maintains compatibility with the odl cache module's behaviour.
  *
  * @param string $cache
  * @throws \Shopware\Components\Api\Exception\NotFoundException
  */
 protected function clearCache($cache)
 {
     $capabilities = $this->cacheManager->getCoreCache()->getBackend()->getCapabilities();
     if ($cache == 'all') {
         $this->cacheManager->getCoreCache()->clean();
         $this->cacheManager->clearHttpCache();
         $this->cacheManager->clearConfigCache();
         $this->cacheManager->clearTemplateCache();
         $this->cacheManager->clearProxyCache();
         $this->cacheManager->clearSearchCache();
         return;
     }
     switch ($cache) {
         case 'http':
             $this->cacheManager->clearHttpCache();
             break;
         case 'config':
             $tags[] = 'Shopware_Config';
             $tags[] = 'Shopware_Plugin';
             $this->cacheManager->clearConfigCache();
             break;
         case 'template':
             $this->cacheManager->clearTemplateCache();
             break;
         case 'backend':
             $tags[] = 'Shopware_Config';
             $tags[] = 'Shopware_Plugin';
             $this->cacheManager->clearTemplateCache();
             break;
         case 'proxy':
             $tags[] = 'Shopware_Models';
             $this->cacheManager->clearProxyCache();
             break;
         case 'doctrine-proxy':
             $tags[] = 'Shopware_Models';
             $this->cacheManager->clearProxyCache();
             break;
         case 'doctrine-file':
             $tags[] = 'Shopware_Models';
             $this->cacheManager->clearProxyCache();
             break;
         case 'search':
             $tags[] = 'Shopware_Modules_Search';
             $this->cacheManager->clearSearchCache();
             break;
         case 'rewrite':
             $this->cacheManager->clearRewriteCache();
             break;
         default:
             throw new ApiException\NotFoundException("Cache {$cache} is not a valid cache id.");
     }
     if (!empty($capabilities['tags'])) {
         if (!empty($tags)) {
             $this->cacheManager->getCoreCache()->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $tags);
         } else {
             $this->cacheManager->getCoreCache()->clean();
         }
     }
 }
Example #2
0
 /**
  * Clear cache action
  */
 public function clearDirectAction()
 {
     $cache = $this->Request()->getQuery('cache');
     switch ($cache) {
         case 'Config':
             $this->cacheManager->clearHttpCache();
             $this->cacheManager->clearTemplateCache();
             $this->cacheManager->clearConfigCache();
             $this->cacheManager->clearSearchCache();
             $this->cacheManager->clearProxyCache();
             break;
         default:
             break;
     }
 }