Projekt

Obecné

Profil

Stáhnout (684 Bajtů) Statistiky
| Větev: | Revize:
1
<?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
class IndexController extends AbstractController
11
{
12
    public function index(DocumentManager $dm): Response
13
    {
14
        $number = random_int(0, 100);
15
        $test = new Test();
16
        $test->setName('A Foo Bar');
17
    
18
        $dm->persist($test);
19
        $dm->flush();
20
        $test = $dm->getRepository(Test::class)->findAll();
21
        return new Response(
22
            '<html><body>Lucky number: '. ($test ? 'not null' : 'null') .'</body></html>'
23
        );
24
    }
25
}
(2-2/2)