1
|
<?php
|
2
|
|
3
|
namespace App\FrontModule\Presenters;
|
4
|
|
5
|
use App\FrontModule\Components\IExampleGirdFactory;
|
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 IExampleGirdFactory */
|
14
|
private $exampleGridFactory;
|
15
|
/** @var ILoginFormFactory */
|
16
|
private $loginFormFactory;
|
17
|
|
18
|
public function __construct(IExampleGirdFactory $exampleGridFactory, ILoginFormFactory $loginFormFactory)
|
19
|
{
|
20
|
parent::__construct();
|
21
|
|
22
|
$this->exampleGridFactory = $exampleGridFactory;
|
23
|
$this->loginFormFactory = $loginFormFactory;
|
24
|
}
|
25
|
|
26
|
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
|
|
39
|
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
|
* @return \App\FrontModule\Components\LoginForm
|
54
|
*/
|
55
|
public function createComponentLoginForm()
|
56
|
{
|
57
|
return $this->loginFormFactory->create();
|
58
|
}
|
59
|
|
60
|
/**
|
61
|
* Vytvoření ukázkového gridu
|
62
|
*/
|
63
|
public function createComponentDataGrid()
|
64
|
{
|
65
|
return $this->exampleGridFactory->create();
|
66
|
}
|
67
|
}
|