Completed
Push — master ( c08e23...fa51b1 )
by Serhii
12s
created

TicketsController::reserveAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace AppBundle\Controller;
4
5
use AppBundle\Entity\Ticket;
6
use FOS\RestBundle\Controller\Annotations\View as RestView;
7
use FOS\RestBundle\Controller\Annotations\RouteResource;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
9
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
10
11
/**
12
 * @RouteResource("Ticket")
13
 */
14
class TicketsController extends Controller
15
{
16
17
    /**
18
     * @ParamConverter("ticket", class="AppBundle:Ticket")
19
     * @RestView(serializerGroups={"get_ticket"})
20
     */
21
    public function getAction(Ticket $ticket)
22
    {
23
        return $ticket;
24
    }
25
26
    /**
27
     * @RestView(statusCode=204)
28
     * @ParamConverter("ticket", class="AppBundle:Ticket")
29
     */
30
    public function freeAction(Ticket $ticket)
31
    {
32
        $em = $this->getDoctrine()->getManager();
33
        $ticket->setStatus(Ticket::STATUS_FREE);
34
        $em->flush();
35
    }
36
37
    /**
38
     * @RestView(statusCode=204)
39
     * @ParamConverter("ticket", class="AppBundle:Ticket")
40
     */
41
    public function reserveAction(Ticket $ticket)
42
    {
43
        $em = $this->getDoctrine()->getManager();
44
        $ticket->setStatus(Ticket::STATUS_BOOKED);
45
        $em->flush();
46
    }
47
}
48