Projekt

Obecné

Profil

Stáhnout (1.52 KB) Statistiky
| Větev: | Tag: | Revize:
1 67c41231 Filip Jani
<?php
2
3 f115c8b5 Filip Jani
namespace App\FrontModule\Presenters;
4 67c41231 Filip Jani
5 f115c8b5 Filip Jani
use App\FrontModule\Components\IExampleGirdFactory;
6
use App\FrontModule\Components\ILoginFormFactory;
7 00f32800 Filip Jani
use App\Enum\EFlashMessage;
8 67c41231 Filip Jani
use Nette;
9
10
11
final class HomepagePresenter extends Nette\Application\UI\Presenter
12
{
13 dd522430 Filip Jani
    /** @var IExampleGirdFactory  */
14
    private $exampleGridFactory;
15 00f32800 Filip Jani
    /** @var ILoginFormFactory */
16
    private $loginFormFactory;
17 dd522430 Filip Jani
18 00f32800 Filip Jani
    public function __construct(IExampleGirdFactory $exampleGridFactory, ILoginFormFactory $loginFormFactory)
19 dd522430 Filip Jani
    {
20
        parent::__construct();
21
22
        $this->exampleGridFactory = $exampleGridFactory;
23 00f32800 Filip Jani
        $this->loginFormFactory = $loginFormFactory;
24 dd522430 Filip Jani
    }
25
26 00f32800 Filip Jani
    public function actionDefault()
27
    {
28
29
    }
30
31
    public function actionLogin()
32
    {
33
        if ($this->user->isLoggedIn())
34
        {
35
            $this->redirect('Homepage:default');
36
        }
37
    }
38 dd522430 Filip Jani
39 00f32800 Filip Jani
    public function actionLogout()
40
    {
41
        if ($this->getUser()->isLoggedIn())
42
        {
43
            $this->user->logout(true);
44
45
            $this->flashMessage('Odhlášení bylo úspěšné.', EFlashMessage::SUCCESS);
46
            $this->redirect('Homepage:default');
47
        }
48
    }
49
50
    /**
51
     * Komponenta přihlašovacího formuláře
52
     *
53 f115c8b5 Filip Jani
     * @return \App\FrontModule\Components\LoginForm
54 00f32800 Filip Jani
     */
55
    public function createComponentLoginForm()
56
    {
57
        return $this->loginFormFactory->create();
58 dd522430 Filip Jani
    }
59
60 00f32800 Filip Jani
    /**
61
     * Vytvoření ukázkového gridu
62
     */
63
    public function createComponentDataGrid()
64
    {
65 dd522430 Filip Jani
        return $this->exampleGridFactory->create();
66
    }
67 67c41231 Filip Jani
}