Completed
Branch master (691237)
by dima
02:39
created

IndexController::get()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 26
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
rs 8.8571
cc 2
eloc 19
nc 2
nop 1
1
<?php
2
3
namespace Frameworkless\Controllers;
4
5
use Symfony\Component\HttpFoundation\Response;
6
use Twig_Environment;
7
use Models\User\Base\UserQuery;
8
use Symfony\Component\VarDumper\VarDumper;
9
10
use Models\User\UserRepo;
11
12
class IndexController
13
{
14
15
    /**
16
     * @var Twig_Environment
17
     */
18
    private $twig;
19
20
    /**
21
     *
22
     * @var \Models\User\UserRepo $UserRepo
23
     */
24
    protected $UserRepo;
25
    
26
    /**
27
     * IndexController, constructed by container
28
     *
29
     * @param Twig_Environment $twig
30
     */
31
    public function __construct(Twig_Environment $twig, UserRepo $UserRepo)
32
    {
33
        $this->twig     = $twig;
34
        $this->UserRepo = $UserRepo;
35
    }
36
37
    /**
38
     * Return index page (/)
39
     *
40
     * @param array $args
41
     * @return Response
42
     */
43
    public function get($args)
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    {
45
46
        $Users = $this->UserRepo->findMany();
47
48
        $table = \Donquixote\Cellbrush\Table\Table::create();
49
        $table->addColNames([0, 1, 2]);
50
        $table->addClass('table table-striped');
51
        $table->thead()
52
                ->addRowName('head row')
53
                ->th('head row', 0, 'Id')
54
                ->th('head row', 1, 'Имя')
55
                ->th('head row', 2, 'Email');
56
        $i = 0;
57
        foreach ($Users as $User) {
58
            $table->addRow($i)->tdMultiple([
59
                $User->getId(),
60
                $User->getName(),
61
                $User->getEmail()]);
62
            $i++;
63
        }
64
65
        return new Response($this->twig->render('pages/index.html.twig',[
66
            "table" => $table->render()
67
        ]));
68
    }
69
}
70