Revize 03c02899
Přidáno uživatelem Jakub Vašta před téměř 5 roky(ů)
website/src/Controller/HeatmapController.php | ||
---|---|---|
2 | 2 |
|
3 | 3 |
namespace App\Controller; |
4 | 4 |
|
5 |
use App\Entity\DataSet; |
|
6 |
use App\Form\Type\DataSetType; |
|
5 | 7 |
use App\OpenData\IOpenDataManager; |
8 |
use Symfony\Component\HttpFoundation\Request; |
|
6 | 9 |
use Symfony\Component\Routing\Annotation\Route; |
7 | 10 |
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
8 | 11 |
|
... | ... | |
10 | 13 |
/** |
11 | 14 |
* @Route("/heatmap", name="heatmap") |
12 | 15 |
*/ |
13 |
public function index() { |
|
14 |
return $this->render('heatmap.html.twig'); |
|
16 |
public function index(Request $request) { |
|
17 |
$dataSet = new DataSet(); |
|
18 |
|
|
19 |
$form = $this->createForm(DataSetType::class, $dataSet); |
|
20 |
$form->handleRequest($request); |
|
21 |
|
|
22 |
// Todo validation |
|
23 |
// $form->isValid() |
|
24 |
$dataSet = $form->getData(); |
|
25 |
if ($form->isSubmitted()) { |
|
26 |
$dataSet = $form->getData(); |
|
27 |
// Todo do something |
|
28 |
} |
|
29 |
|
|
30 |
return $this->render( |
|
31 |
'heatmap.html.twig', |
|
32 |
[ |
|
33 |
'form' => $form->createView(), |
|
34 |
] |
|
35 |
); |
|
15 | 36 |
} |
16 | 37 |
|
17 | 38 |
/** |
... | ... | |
20 | 41 |
public function opendata(IOpenDataManager $manager, $collectionName) { |
21 | 42 |
return $this->json($manager->getCollectionDataByName($collectionName)); |
22 | 43 |
} |
44 |
|
|
45 |
/** |
|
46 |
* @Route("heatmap/available/{date}", name="available") |
|
47 |
*/ |
|
48 |
public function availableDatasets(IOpenDataManager $manager, $date = '01012020') { |
|
49 |
return $this->json($manager->getAvailableCollectionsByDay($date)); |
|
50 |
} |
|
23 | 51 |
} |
Také k dispozici: Unified diff
Re #7933
+ základní funkcionalita formulářů v aplikaci - viz. Symfony forms