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