Replaces the CacheController

This commit is contained in:
Franck Allimant
2014-04-24 16:24:20 +02:00
parent 2f5ea0927a
commit 6e5c461c79
2 changed files with 107 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
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\CacheFlushForm;
use Thelia\Form\Exception\FormValidationException;
/**
* Class CacheController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class AdvancedConfigurationController extends BaseAdminController
{
public function defaultAction()
{
if (null !== $result = $this->checkAuth(AdminResources::ADVANCED_CONFIGURATION, [], AccessManager::VIEW)) {
return $result;
}
return $this->render('advanced-configuration');
}
public function flushCacheAction()
{
if (null !== $result = $this->checkAuth(AdminResources::ADVANCED_CONFIGURATION, [], AccessManager::UPDATE)) {
return $result;
}
$form = new CacheFlushForm($this->getRequest());
try {
$this->validateForm($form);
$event = new CacheEvent($this->container->getParameter("kernel.cache_dir"));
$this->dispatch(TheliaEvents::CACHE_CLEAR, $event);
$event = new CacheEvent(THELIA_WEB_DIR . "assets");
$this->dispatch(TheliaEvents::CACHE_CLEAR, $event);
$this->redirectToRoute('admin.configuration.advanced');
} catch (FormValidationException $e) {
}
}
}

View File

@@ -0,0 +1,47 @@
{extends file="admin-layout.tpl"}
{block name="page-title"}{intl l='Cache'}{/block}
{block name="check-resource"}admin.cache{/block}
{block name="check-access"}view{/block}
{block name="main-content"}
<div class="variables edit-variable">
<div id="wrapper" class="container">
<ul class="breadcrumb">
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
<li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a></li>
<li>{intl l="Advanced configuration"}</li>
</ul>
<div class="row">
<div class="col-md-12 general-block-decorator">
<div class="row">
<div class="col-md-12 title title-without-tabs">
{intl l='Advanced configuration'}
</div>
<div class="form-container">
<div class="col-md-6">
{form name="thelia.cache.flush"}
<form method="post" action="{url path="/admin/configuration/advanced/flush-cache"}">
{form_hidden_fields form=$form}
<div class="form-group">
<label class="control-label">{intl l="Flush the Thelia internal cache"} : </label>
<button type="submit" class="btn btn-warning btn-sm">{intl l="Flush the cache now"}</button>
</div>
</form>
{/form}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{/block}