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

WidgetCacheController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 5
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A clearAction() 0 9 2
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