Revize 55098dbb
Přidáno uživatelem Tomáš Ballák před více než 4 roky(ů)
- ID 55098dbb88feff1302dfdabf4c1c162a2f8444f2
- Rodič fa91b0c1
website/src/Controller/HeatmapController.php | ||
---|---|---|
2 | 2 |
|
3 | 3 |
namespace App\Controller; |
4 | 4 |
|
5 |
use App\Entity\OpenData; |
|
6 |
use MongoDB\Driver\Query; |
|
7 |
use MongoDB\Driver\Manager; |
|
5 |
use App\OpenData\IOpenDataManager; |
|
8 | 6 |
use Symfony\Component\Routing\Annotation\Route; |
9 | 7 |
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
10 | 8 |
|
... | ... | |
13 | 11 |
* @Route("/heatmap") |
14 | 12 |
*/ |
15 | 13 |
public function index() { |
16 |
$manager = new Manager( |
|
17 |
'mongodb://root:root@database' |
|
18 |
); |
|
19 |
|
|
20 |
$openData = $manager->executeQuery('open-data-db.KOLOBEZKY31102018', new Query([], [])); |
|
21 |
$openData->setTypeMap([ |
|
22 |
'array' => 'array', |
|
23 |
'document' => 'array', |
|
24 |
'root' => 'array', |
|
25 |
]); |
|
26 |
|
|
27 |
return $this->render('heatmap.html.twig', [ |
|
28 |
'open_data' => $openData->toArray(), |
|
29 |
]); |
|
14 |
return $this->render('heatmap.html.twig'); |
|
30 | 15 |
} |
31 | 16 |
|
32 | 17 |
/** |
33 |
* @Route("heatmap/opendata", name="opendata") |
|
18 |
* @Route("heatmap/opendata/{collectionName}", name="opendata")
|
|
34 | 19 |
*/ |
35 |
public function opendata() { |
|
36 |
$manager = new Manager( |
|
37 |
'mongodb://root:root@database' |
|
38 |
); |
|
39 |
|
|
40 |
$openData = $manager->executeQuery('open-data-db.KOLOBEZKY31102018', new Query([], [])); |
|
41 |
$openData->setTypeMap([ |
|
42 |
'array' => 'array', |
|
43 |
'document' => 'array', |
|
44 |
'root' => 'array', |
|
45 |
]); |
|
46 |
|
|
47 |
return $this->json($openData->toArray()); |
|
20 |
public function opendata(IOpenDataManager $manager, $collectionName) { |
|
21 |
return $this->json($manager->getCollectionDataByName($collectionName)); |
|
48 | 22 |
} |
49 | 23 |
} |
Také k dispozici: Unified diff
Re #7857