Completed
Pull Request — master (#136)
by
unknown
11:23
created

PerformanceEventCRUDController::getVenueAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
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