1 |
1cfcde53
|
Tomáš Ballák
|
<?php
|
2 |
|
|
|
3 |
|
|
namespace App\Controller;
|
4 |
|
|
|
5 |
|
|
use App\Document\Test;
|
6 |
|
|
use Doctrine\ODM\MongoDB\DocumentManager;
|
7 |
|
|
use Symfony\Component\HttpFoundation\Response;
|
8 |
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
9 |
|
|
|
10 |
343d66a7
|
Tomáš Ballák
|
class IndexController extends AbstractController
|
11 |
|
|
{
|
12 |
|
|
public function index(DocumentManager $dm): Response
|
13 |
|
|
{
|
14 |
1cfcde53
|
Tomáš Ballák
|
$number = random_int(0, 100);
|
15 |
343d66a7
|
Tomáš Ballák
|
$test = new Test();
|
16 |
|
|
$test->setName('A Foo Bar');
|
17 |
|
|
|
18 |
|
|
$dm->persist($test);
|
19 |
|
|
$dm->flush();
|
20 |
1cfcde53
|
Tomáš Ballák
|
$test = $dm->getRepository(Test::class)->findAll();
|
21 |
|
|
return new Response(
|
22 |
343d66a7
|
Tomáš Ballák
|
'<html><body>Lucky number: '. ($test ? 'not null' : 'null') .'</body></html>'
|
23 |
1cfcde53
|
Tomáš Ballák
|
);
|
24 |
|
|
}
|
25 |
|
|
}
|