Conditions | 3 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 14 |
Lines | 22 |
Ratio | 100 % |
Tests | 14 |
CRAP Score | 3 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | 3 | public function execute() |
|
22 | { |
||
23 | 3 | $classMetaData = $this->getMatchedRoute()->getClassMetaData(); |
|
24 | 3 | $elementName = $classMetaData->getEntityAlias(); |
|
25 | |||
26 | 3 | $em = $this->getEntityManager(); |
|
27 | 3 | $qb = $em->createQueryBuilder()->from($classMetaData->getClassName(), $elementName); |
|
28 | 3 | $this->registerExposeFromMetaData($qb, $em->getClassMetadata($classMetaData->getClassName())); |
|
29 | |||
30 | 3 | foreach ($this->getMatchedRoute()->getRouteParams() as $key => $value) { |
|
31 | 2 | $qb->andWhere($elementName . '.' . $key . ' = :' . $key); |
|
32 | 2 | $qb->setParameter($key, $value); |
|
33 | 3 | } |
|
34 | |||
35 | try { |
||
36 | 3 | $resultSet = $this->createResultSet($qb->getQuery()->getSingleResult(ORM\Query::HYDRATE_ARRAY)); |
|
37 | 3 | } catch (\Exception $e) { |
|
38 | 2 | return $this->handleError($e, Response::STATUS_CODE_404); |
|
39 | } |
||
40 | |||
41 | 1 | return $resultSet; |
|
42 | } |
||
43 | } |
||
44 |