| Code Coverage
| Classes and Traits | Functions and Methods | Lines
Total |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 1 | CRAP |  | 0.00% | 0 / 28
ProfileController |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 1 | 20 |  | 0.00% | 0 / 27
indexAction($username) |  | 0.00% | 0 / 1 | 20 |  | 0.00% | 0 / 27

1 | <?php
2 |
3 | namespace BodyRep\Controller;
4 |
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6 | use Symfony\Component\Security\Core\SecurityContext;
7 | use Symfony\Component\HttpFoundation\RedirectResponse;
8 | use JMS\SecurityExtraBundle\Annotation\Secure;
9 |
10 | # Annotations
11 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
12 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
13 |
14 | class ProfileController extends Controller
15 | {
16 | /**
17 | * @Route("/{username}", name="_profile")
18 | * @Template()
19 | */
20 | public function indexAction($username)
21 | {
22 | if ($this->getUser()->getUsername() == $username)
23 | return new RedirectResponse($this->generateUrl('_member_profile'));
24 |
25 | $db = $this->getDoctrine()->getManager();
26 |
27 | $query = $db->createQuery('
28 | SELECT p
29 | FROM BodyRep:Profile p
30 | WHERE p.username = :username')
31 | ->setParameter('username', $username)
32 | ->setMaxResults(1);
33 | if (sizeof($query->getResult()) != 1)
34 | throw $this->createNotFoundException("User '".$username."' not found");
35 |
36 | $profile = $query->getSingleResult();
37 | $username = $this->getUser()->getUsername();
38 | $db = $this->getDoctrine()->getManager();
39 | $query = $db->createQuery('
40 | SELECT m
41 | FROM BodyRep:Member m
42 | WHERE m.username = :username')
43 | ->setParameter('username', $username)
44 | ->setMaxResults(1);
45 |
46 | if (sizeof($query->getResult()) != 1)
47 | throw $this->createNotFoundException("User '".$username."' not found");
48 |
49 | $member = $query->getSingleResult();
50 |
51 |
52 | return (array('sFullName' => $profile->getFullName(), 'name' => $member->getFullName()));
53 |
54 | }
55 |
56 |
57 | }