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 |
|||
| <?php | |
| namespace BodyRep\Controller; | |
| use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
| use Symfony\Component\Security\Core\SecurityContext; | |
| use Symfony\Component\HttpFoundation\RedirectResponse; | |
| use JMS\SecurityExtraBundle\Annotation\Secure; | |
| # Annotations | |
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; | |
| class ProfileController extends Controller | |
| { | |
| /** | |
| * @Route("/{username}", name="_profile") | |
| * @Template() | |
| */ | |
| public function indexAction($username) | |
| { | |
| if ($this->getUser()->getUsername() == $username) | |
| return new RedirectResponse($this->generateUrl('_member_profile')); | |
| $db = $this->getDoctrine()->getManager(); | |
| $query = $db->createQuery(' | |
| SELECT p | |
| FROM BodyRep:Profile p | |
| WHERE p.username = :username') | |
| ->setParameter('username', $username) | |
| ->setMaxResults(1); | |
| if (sizeof($query->getResult()) != 1) | |
| throw $this->createNotFoundException("User '".$username."' not found"); | |
| $profile = $query->getSingleResult(); | |
| $username = $this->getUser()->getUsername(); | |
| $db = $this->getDoctrine()->getManager(); | |
| $query = $db->createQuery(' | |
| SELECT m | |
| FROM BodyRep:Member m | |
| WHERE m.username = :username') | |
| ->setParameter('username', $username) | |
| ->setMaxResults(1); | |
| if (sizeof($query->getResult()) != 1) | |
| throw $this->createNotFoundException("User '".$username."' not found"); | |
| $member = $query->getSingleResult(); | |
| return (array('sFullName' => $profile->getFullName(), 'name' => $member->getFullName())); | |
| } | |
| } |