Conditions | 3 |
Paths | 8 |
Total Lines | 23 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
20 | 3 | public function execute() |
|
21 | { |
||
22 | 3 | $matchedRoute = $this->getMatchedRoute(); |
|
23 | 3 | $classMetaData = $matchedRoute->getClassMetaData(); |
|
24 | 3 | $elementName = $classMetaData->getEntityAlias(); |
|
25 | |||
26 | 3 | $em = $this->getEntityManager(); |
|
27 | |||
28 | 3 | $qb = $em->createQueryBuilder()->delete($classMetaData->getClassName(), $elementName); |
|
29 | 3 | foreach ($matchedRoute->getRouteParams() as $key => $value) { |
|
30 | 2 | $qb->andWhere($elementName . '.' . $key . ' = :' . $key); |
|
31 | 2 | $qb->setParameter($key, $value); |
|
32 | 3 | } |
|
33 | |||
34 | try { |
||
35 | 3 | $qb->getQuery()->execute(); |
|
36 | 2 | $this->getResponse()->setStatusCode(Response::STATUS_CODE_200); |
|
37 | |||
38 | 2 | return ResultSet::create(['successfully deleted'], 'response'); |
|
39 | 1 | } catch (\Exception $e) { |
|
40 | 1 | return $this->handleError($e, Response::STATUS_CODE_500); |
|
41 | } |
||
42 | } |
||
43 | } |
||
44 |