-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccountPresenterTrait.php
More file actions
68 lines (57 loc) · 2.02 KB
/
Copy pathAccountPresenterTrait.php
File metadata and controls
68 lines (57 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
declare(strict_types=1);
namespace ADT\FancyAdmin\UI\Presenters\Account;
use ADT\FancyAdmin\DI\Injects\AuthenticatorInject;
use ADT\FancyAdmin\DI\Injects\ChangePasswordFormFactoryInject;
use ADT\FancyAdmin\DI\Injects\PersonalDataFormFactoryInject;
use ADT\FancyAdmin\DI\Injects\SecurityUserInject;
use ADT\FancyAdmin\UI\Components\Controls\SidePanel\SidePanelControl;
use ADT\FancyAdmin\UI\Components\Controls\SidePanel\SidePanelControlFactory;
use ADT\FancyAdmin\UI\Components\Grids\Session\SessionGrid;
use ADT\FancyAdmin\UI\Components\Grids\Session\SessionGridFactory;
use ADT\FancyAdmin\UI\Presenters\PresenterTrait;
trait AccountPresenterTrait
{
use PresenterTrait;
use SecurityUserInject;
use AuthenticatorInject;
use PersonalDataFormFactoryInject;
use ChangePasswordFormFactoryInject;
public function actionDefault(): void
{
$this->getTemplate()->identity = $this->_securityUser->getIdentity();
$this->getTemplate()->setFile(__DIR__ . '/default.latte');
}
public function handleEditPersonalData(): void
{
$this->redrawSidePanel('personalData');
}
public function handleChangePassword(): void
{
$this->redrawSidePanel('changePassword');
}
public function handleLogoutAll(): never
{
$this->_authenticator->clearIdentity(
$this->_securityUser->getIdentity()->getAuthObjectId()
);
$this->getUser()->logout(true);
$this->redirect(':Portal:Sign:in');
}
public function createComponentPersonalDataSidePanel(SidePanelControlFactory $factory): SidePanelControl
{
return $factory->create()
->setFormFactory(fn() => $this->_personalDataFormFactory->create()
->setEntity($this->_securityUser->getIdentity()));
}
public function createComponentChangePasswordSidePanel(SidePanelControlFactory $factory): SidePanelControl
{
return $factory->create()
->setFormFactory(fn() => $this->_changePasswordFormFactory->create()
->setEntity($this->_securityUser->getIdentity()));
}
public function createComponentSessionGrid(SessionGridFactory $factory): SessionGrid
{
return $factory->create();
}
}