Failed Conditions
Push — issue#666 ( 82e9d5...91903a )
by Guilherme
08:00
created

InvalidateSessionsController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A invalidateAction() 0 20 2
1
<?php
2
/*
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\CoreBundle\Controller;
12
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
15
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
16
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
17
use LoginCidadao\CoreBundle\Entity\InvalidateSessionRequest;
18
19
/**
20
 * @Route("/invalidate")
21
 */
22
class InvalidateSessionsController extends Controller
23
{
24
25
    /**
26
     * @Route("/invalidate", name="lc_invalidate_sessions")
27
     * @Template()
28
     */
29
    public function invalidateAction(Request $request)
30
    {
31
        $invalidate = new InvalidateSessionRequest();
32
33
        $type = 'LoginCidadao\CoreBundle\Form\InvalidateSessionRequestType';
34
        $form = $this->createForm($type, $invalidate);
35
        $form->handleRequest($request);
36
37
        if ($form->isValid()) {
38
            $invalidate->setPerson($this->getUser())
39
                ->setRequestedAt(new \DateTime());
40
41
            $em = $this->getDoctrine()->getManager();
42
            $em->persist($invalidate);
43
            $em->flush($invalidate);
44
45
            return $this->redirectToRoute('fos_user_security_logout');
46
        }
47
48
        return compact('form');
49
    }
50
}
51