1
|
<?php
|
2
|
|
3
|
namespace App\FrontModule\Presenters;
|
4
|
|
5
|
use App\FrontModule\Components\IUserSettingsFormFactory;
|
6
|
use App\FrontModule\Components\IExampleGirdFactory;
|
7
|
use App\FrontModule\Components\ILoginFormFactory;
|
8
|
use App\Enum\EFlashMessage;
|
9
|
use Nette;
|
10
|
|
11
|
|
12
|
final class HomepagePresenter extends Nette\Application\UI\Presenter
|
13
|
{
|
14
|
/** @var IExampleGirdFactory */
|
15
|
private $exampleGridFactory;
|
16
|
/** @var ILoginFormFactory */
|
17
|
private $loginFormFactory;
|
18
|
|
19
|
/** @var IUserSettingsFormFactory */
|
20
|
private $userSettingsFormFactory;
|
21
|
|
22
|
public function __construct(IExampleGirdFactory $exampleGridFactory,
|
23
|
ILoginFormFactory $loginFormFactory,
|
24
|
IUserSettingsFormFactory $userSettingsFormFactory
|
25
|
)
|
26
|
{
|
27
|
parent::__construct();
|
28
|
|
29
|
$this->exampleGridFactory = $exampleGridFactory;
|
30
|
$this->loginFormFactory = $loginFormFactory;
|
31
|
$this->userSettingsFormFactory = $userSettingsFormFactory;
|
32
|
}
|
33
|
|
34
|
public function actionDefault()
|
35
|
{
|
36
|
|
37
|
}
|
38
|
|
39
|
public function actionUserSettings()
|
40
|
{
|
41
|
if (!$this->getUser()->isLoggedIn())
|
42
|
{
|
43
|
$this->redirect('Homepage:default');
|
44
|
}
|
45
|
}
|
46
|
|
47
|
public function actionLogin()
|
48
|
{
|
49
|
if ($this->user->isLoggedIn())
|
50
|
{
|
51
|
$this->redirect('Homepage:default');
|
52
|
}
|
53
|
}
|
54
|
|
55
|
public function actionLogout()
|
56
|
{
|
57
|
if ($this->getUser()->isLoggedIn())
|
58
|
{
|
59
|
$this->user->logout(true);
|
60
|
|
61
|
$this->flashMessage('Odhlášení bylo úspěšné.', EFlashMessage::SUCCESS);
|
62
|
$this->redirect('Homepage:default');
|
63
|
}
|
64
|
}
|
65
|
|
66
|
/**
|
67
|
* Komponenta přihlašovacího formuláře
|
68
|
*
|
69
|
* @return \App\FrontModule\Components\LoginForm
|
70
|
*/
|
71
|
public function createComponentLoginForm()
|
72
|
{
|
73
|
return $this->loginFormFactory->create();
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* @return \App\FrontModule\Components\UserSettingsForm
|
78
|
*/
|
79
|
public function createComponentUserSettingsForm(){
|
80
|
return $this->userSettingsFormFactory->create();
|
81
|
}
|
82
|
|
83
|
/**
|
84
|
* Vytvoření ukázkového gridu
|
85
|
*/
|
86
|
public function createComponentDataGrid()
|
87
|
{
|
88
|
return $this->exampleGridFactory->create();
|
89
|
}
|
90
|
}
|