Completed
Push — master ( 28be56...359087 )
by Serhii
13:20
created

PerformanceEventCRUDController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A deletePriceCategoriesAction() 0 12 2
A getVenueAction() 0 9 1
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 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
        foreach ($performanceEvent->getPriceCategories() as $priceCategory) {
32
            $performanceEvent->removePriceCategories($priceCategory);
33
            $em->remove($priceCategory);
34
            $em->flush();
35
        }
36
        return new Response();
37
    }
38
}
39