|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Controller; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
|
6
|
|
|
|
|
7
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
8
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
9
|
|
|
|
|
10
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
11
|
|
|
|
|
12
|
|
|
use App\Manager\Community\{ |
|
13
|
|
|
CommunityManager, |
|
14
|
|
|
MemberManager, |
|
15
|
|
|
NewsManager, |
|
16
|
|
|
ProjectManager |
|
17
|
|
|
}; |
|
18
|
|
|
|
|
19
|
|
|
class CommunityController extends Controller |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @Route("/communities/new", name="new_community", methods={"GET"}) |
|
23
|
|
|
*/ |
|
24
|
1 |
|
public function newAction() |
|
25
|
|
|
{ |
|
26
|
1 |
|
return $this->render('communities/new.html.twig'); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @Route("/communities", name="create_community", methods={"POST"}) |
|
31
|
|
|
*/ |
|
32
|
1 |
|
public function createAction(Request $request, CommunityManager $communityManager) |
|
33
|
|
|
{ |
|
34
|
1 |
|
return new JsonResponse($communityManager->createCommunity( |
|
35
|
1 |
|
$this->getUser(), |
|
36
|
1 |
|
$request->request->get('name'), |
|
37
|
1 |
|
$request->files->get('picture') |
|
38
|
1 |
|
), 201); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @Route("/communities", name="communities_list", methods={"GET"}) |
|
43
|
|
|
*/ |
|
44
|
1 |
|
public function getAllAction(CommunityManager $communityManager) |
|
45
|
|
|
{ |
|
46
|
1 |
|
return $this->render('communities/list.html.twig', [ |
|
47
|
1 |
|
'communities' => $communityManager->getAll() |
|
48
|
|
|
]); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @Route("/communities/{slug}", name="community_details", methods={"GET"}) |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getAction(string $slug, CommunityManager $communityManager, MemberManager $memberManager, NewsManager $newsManager, ProjectManager $projectManager) |
|
55
|
|
|
{ |
|
56
|
|
|
$community = $communityManager->get($slug); |
|
57
|
|
|
return $this->render('communities/details.html.twig', [ |
|
58
|
|
|
'community' => $community, |
|
59
|
|
|
'members' => $memberManager->getCommunityMembers($community), |
|
60
|
|
|
'news' => $newsManager->getCommunityNews($community), |
|
61
|
|
|
'projects' => $projectManager->getCommunityProjects($community), |
|
62
|
|
|
]); |
|
63
|
|
|
} |
|
64
|
|
|
} |