Completed
Push — master ( 904db4...e42307 )
by Leny
18s
created

WidgetCacheController::clearAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace Victoire\Bundle\WidgetBundle\Controller;
4
5
use Exception;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\Response;
10
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
11
use Victoire\Bundle\CoreBundle\Controller\VictoireAlertifyControllerTrait;
12
13
/**
14
 * Widget Cache Controller.
15
 */
16
class WidgetCacheController extends Controller
17
{
18
    use VictoireAlertifyControllerTrait;
19
20
    /**
21
     * Clear the widgetcache.
22
     *
23
     * @param Request $request
24
     *
25
     * @Route("/victoire-dcms-public/widget-cache/clear", name="victoire_core_widget_cache_clear")
26
     *
27
     * @throws Exception
28
     *
29
     * @return Response
30
     */
31
    public function clearAction(Request $request)
32
    {
33
        if (!$this->getParameter('kernel.debug')) {
34
            throw new AccessDeniedException('You should be in debug mode to access this feature');
35
        }
36
        $this->get('victoire_widget.widget_cache')->clear();
37
38
        return $this->redirect($request->headers->get('referer'));
39
    }
40
}
41