Completed
Pull Request — master (#136)
by
unknown
12:19
created

PerformanceEventCRUDController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getVenueAction() 0 9 1
A deletePriceCategoriesAction() 0 13 2
1
<?php
2
3
namespace AppBundle\Controller;
4
5
use Sonata\AdminBundle\Controller\CRUDController;
6
use Symfony\Component\HttpFoundation\Response;
7
8
class PerformanceEventCRUDController extends CRUDController
9
{
10
    /**
11
     * @return Response
12
     */
13
    public function getVenueAction()
14
    {
15
        $id = $this->get('request')->query->get('venue_id');
16
        $venue = $this->getDoctrine()->getRepository('AppBundle:Venue')->find($id);
17
18
        return $this->render('AppBundle:PerformanceEventCRUD:venueHall.html.twig', [
19
            'venue' => $venue,
20
        ]);
21
    }
22
23
    /**
24
     * @return bool|Response
25
     */
26
    public function deletePriceCategoriesAction()
27
    {
28
        $performanceEventId = $this->get('request')->query->get('performanceEvent_id');
29
        $em = $this->getDoctrine()->getManager();
30
        $performanceEvent = $em->getRepository('AppBundle:PerformanceEvent')->find($performanceEventId);
31
        $priceCategories = $performanceEvent->getPriceCategories();
32
        foreach ($priceCategories as $priceCategory) {
33
            $performanceEvent->removePriceCategories($priceCategory);
34
            $em->persist($performanceEvent);
35
        }
36
        $em->flush();
37
        return new Response();
38
    }
39
}
40