Completed
Pull Request — master (#362)
by Paul
08:59 queued 02:20
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 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