Merge pull request #345 from roadster31/various-fixes

Various fixes
This commit is contained in:
Manuel Raynaud
2014-04-28 21:56:01 +02:00
20 changed files with 466 additions and 269 deletions

View File

@@ -16,8 +16,12 @@ use Thelia\Core\Event\Cache\CacheEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Form\Cache\AssetsFlushForm;
use Thelia\Form\Cache\CacheFlushForm;
use Thelia\Form\Cache\ImagesAndDocumentsCacheFlushForm;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Log\Tlog;
use Thelia\Model\ConfigQuery;
/**
* Class CacheController
@@ -49,12 +53,53 @@ class AdvancedConfigurationController extends BaseAdminController
$event = new CacheEvent($this->container->getParameter("kernel.cache_dir"));
$this->dispatch(TheliaEvents::CACHE_CLEAR, $event);
} catch (\Exception $e) {
Tlog::getInstance()->addError(sprintf("Flush cache error: %s", $e->getMessage()));
}
$this->redirectToRoute('admin.configuration.advanced');
}
public function flushAssetsAction()
{
if (null !== $result = $this->checkAuth(AdminResources::ADVANCED_CONFIGURATION, [], AccessManager::UPDATE)) {
return $result;
}
$form = new AssetsFlushForm($this->getRequest());
try {
$this->validateForm($form);
$event = new CacheEvent(THELIA_WEB_DIR . "assets");
$this->dispatch(TheliaEvents::CACHE_CLEAR, $event);
$this->redirectToRoute('admin.configuration.advanced');
} catch (FormValidationException $e) {
} catch (\Exception $e) {
Tlog::getInstance()->addError(sprintf("Flush assets error: %s", $e->getMessage()));
}
$this->redirectToRoute('admin.configuration.advanced');
}
public function flushImagesAndDocumentsAction()
{
if (null !== $result = $this->checkAuth(AdminResources::ADVANCED_CONFIGURATION, [], AccessManager::UPDATE)) {
return $result;
}
$form = new ImagesAndDocumentsCacheFlushForm($this->getRequest());
try {
$this->validateForm($form);
$event = new CacheEvent(THELIA_WEB_DIR . ConfigQuery::read('image_cache_dir_from_web_root', 'cache'));
$this->dispatch(TheliaEvents::CACHE_CLEAR, $event);
$event = new CacheEvent(THELIA_WEB_DIR . ConfigQuery::read('document_cache_dir_from_web_root', 'cache'));
$this->dispatch(TheliaEvents::CACHE_CLEAR, $event);
} catch (\Exception $e) {
Tlog::getInstance()->addError(sprintf("Flush images and document error: %s", $e->getMessage()));
}
$this->redirectToRoute('admin.configuration.advanced');
}
}