Projekt

Obecné

Profil

Stáhnout (1.79 KB) Statistiky
| Větev: | Tag: | Revize:
1
<?php
2

    
3
namespace App\FrontModule\Presenters;
4

    
5
use App\FrontModule\Components\IUserSettingsFormFactory;
6
use App\FrontModule\Components\ILoginFormFactory;
7
use App\Enum\EFlashMessage;
8
use Nette;
9

    
10

    
11
final class HomepagePresenter extends Nette\Application\UI\Presenter
12
{
13
    /** @var ILoginFormFactory */
14
    private $loginFormFactory;
15

    
16
    /** @var IUserSettingsFormFactory */
17
    private $userSettingsFormFactory;
18

    
19
    public function __construct(ILoginFormFactory $loginFormFactory,
20
                                IUserSettingsFormFactory $userSettingsFormFactory
21
    )
22
    {
23
        parent::__construct();
24

    
25
        $this->loginFormFactory = $loginFormFactory;
26
        $this->userSettingsFormFactory = $userSettingsFormFactory;
27
    }
28

    
29
    public function actionDefault()
30
    {
31

    
32
    }
33

    
34
    public function actionUserSettings()
35
    {
36
        if (!$this->getUser()->isLoggedIn())
37
        {
38
            $this->redirect('Homepage:default');
39
        }
40
    }
41

    
42
    public function actionLogin()
43
    {
44
        if ($this->user->isLoggedIn())
45
        {
46
            $this->redirect('Homepage:default');
47
        }
48
    }
49

    
50
    public function actionLogout()
51
    {
52
        if ($this->getUser()->isLoggedIn())
53
        {
54
            $this->user->logout(true);
55

    
56
            $this->flashMessage('Odhlášení bylo úspěšné.', EFlashMessage::SUCCESS);
57
            $this->redirect('Homepage:default');
58
        }
59
    }
60

    
61
    /**
62
     * Komponenta přihlašovacího formuláře
63
     *
64
     * @return \App\FrontModule\Components\LoginForm
65
     */
66
    public function createComponentLoginForm()
67
    {
68
        return $this->loginFormFactory->create();
69
    }
70

    
71
    /**
72
     * @return \App\FrontModule\Components\UserSettingsForm
73
     */
74
    public function createComponentUserSettingsForm(){
75
        return $this->userSettingsFormFactory->create();
76
    }
77
}
(5-5/6)