Completed
Pull Request — master (#362)
by Paul
08:59 queued 02:20
created

WidgetCacheController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
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 Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
8
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
10
use Symfony\Component\HttpFoundation\Response;
11
use Symfony\Component\HttpFoundation\Request;
12
use Victoire\Bundle\CoreBundle\Controller\VictoireAlertifyControllerTrait;
13
14
/**
15
 * Widget Cache Controller.
16
 */
17
class WidgetCacheController extends Controller
18
{
19
    use VictoireAlertifyControllerTrait;
20
21
    /**
22
     * Clear the widgetcache.
23
     *
24
     * @param Request $request
25
     *
26
     * @Route("/victoire-dcms-public/widget-cache/clear", name="victoire_core_widget_cache_clear")
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
}
42