Commit | Line | Data |
---|---|---|
929ca066 BA |
1 | <?php |
2 | ||
3 | namespace Mixstore\UserBundle\Controller; | |
4 | ||
5 | use Symfony\Component\HttpFoundation\Response; | |
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
7 | ||
8 | class BoardController extends Controller | |
9 | { | |
10 | public function indexAction() | |
11 | { | |
12 | if (is_null($this->getUser())) | |
13 | //TODO: nice error page | |
14 | return $this->redirect($this->generateUrl('mixstore_static_home')); | |
15 | ||
16 | $em = $this | |
17 | ->getDoctrine() | |
18 | ->getManager(); | |
19 | ||
20 | $ucsRepository = $em | |
21 | ->getRepository('MixstoreStoreBundle:Usecase'); | |
22 | ||
23 | $usecases = $ucsRepository | |
24 | ->findByUser($this->getUser()->getId()); | |
25 | ||
26 | for ($i=0; $i<count($usecases); $i++) | |
27 | $usecases[$i]->software = $usecases[$i]->getPackage()->getName(); | |
28 | ||
29 | $packages = $em | |
30 | ->getRepository('MixstoreStoreBundle:Package') | |
31 | ->findByUser($this->getUser()->getId()); | |
32 | ||
33 | //TODO: fix code redundancy (see PackageController.php) | |
34 | for ($i=0; $i<count($packages); $i++) | |
35 | { | |
36 | $countAndRating = $ucsRepository->countByPkgId($packages[$i]->getId()); | |
37 | if (is_null($countAndRating['rating']) || $countAndRating['rating'] == '') | |
38 | $countAndRating['rating'] = 'NA'; | |
39 | $packages[$i]->ucscount = $countAndRating['ucscount']; | |
40 | $packages[$i]->rating = $countAndRating['rating']; | |
41 | } | |
42 | ||
43 | return $this->render('MixstoreUserBundle:Board:index.html.twig', array( | |
44 | 'packages' => $packages, | |
45 | 'usecases' => $usecases, | |
46 | )); | |
47 | } | |
48 | } |