|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace VSV\GVQ_API\Question\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use function GuzzleHttp\Promise\all; |
|
6
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
|
7
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
8
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
9
|
|
|
use VSV\GVQ_API\Factory\ModelsFactory; |
|
10
|
|
|
use VSV\GVQ_API\Question\Repositories\CategoryRepository; |
|
11
|
|
|
use VSV\GVQ_API\Question\Repositories\QuestionRepository; |
|
12
|
|
|
|
|
13
|
|
|
class QuestionViewController extends AbstractController |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var QuestionRepository |
|
17
|
|
|
*/ |
|
18
|
|
|
private $questionRepository; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var CategoryRepository |
|
22
|
|
|
*/ |
|
23
|
|
|
private $categoryRepository; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param QuestionRepository $questionRepository |
|
27
|
|
|
* @param CategoryRepository $categoryRepository |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct( |
|
30
|
|
|
QuestionRepository $questionRepository, |
|
31
|
|
|
CategoryRepository $categoryRepository |
|
32
|
|
|
) { |
|
33
|
|
|
$this->questionRepository = $questionRepository; |
|
34
|
|
|
$this->categoryRepository = $categoryRepository; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @return Response |
|
39
|
|
|
*/ |
|
40
|
|
|
public function index(): Response |
|
41
|
|
|
{ |
|
42
|
|
|
$questions = $this->questionRepository->getAll(); |
|
43
|
|
|
|
|
44
|
|
|
return $this->render( |
|
45
|
|
|
'questions/index.html.twig', |
|
46
|
|
|
[ |
|
47
|
|
|
'questions' => $questions ? $questions->toArray() : [], |
|
48
|
|
|
] |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param Request $request |
|
54
|
|
|
* @return Response |
|
55
|
|
|
*/ |
|
56
|
|
|
public function add(Request $request): Response |
|
57
|
|
|
{ |
|
58
|
|
|
var_dump($request->request->all()); |
|
|
|
|
|
|
59
|
|
|
var_dump($request->files); |
|
60
|
|
|
|
|
61
|
|
|
$categories = $this->categoryRepository->getAll(); |
|
62
|
|
|
return $this->render( |
|
63
|
|
|
'questions/add.html.twig', |
|
64
|
|
|
[ |
|
65
|
|
|
'categories' => $categories ? $categories->toArray() : [], |
|
66
|
|
|
] |
|
67
|
|
|
); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|