1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AbterPhp\Admin\Http\Controllers\Admin\Form; |
6
|
|
|
|
7
|
|
|
use AbterPhp\Admin\Constant\Routes; |
8
|
|
|
use AbterPhp\Admin\Form\Factory\Profile as FormFactory; |
9
|
|
|
use AbterPhp\Admin\Orm\UserRepo as Repo; |
10
|
|
|
use AbterPhp\Framework\Assets\AssetManager; |
11
|
|
|
use AbterPhp\Framework\Constant\Session; |
12
|
|
|
use AbterPhp\Framework\I18n\ITranslator; |
13
|
|
|
use AbterPhp\Framework\Session\FlashService; |
14
|
|
|
use Opulence\Events\Dispatchers\IEventDispatcher; |
15
|
|
|
use Opulence\Routing\Urls\UrlGenerator; |
16
|
|
|
use Opulence\Sessions\ISession; |
17
|
|
|
|
18
|
|
|
class Profile extends User |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* User constructor. |
22
|
|
|
* |
23
|
|
|
* @param FlashService $flashService |
24
|
|
|
* @param ITranslator $translator |
25
|
|
|
* @param UrlGenerator $urlGenerator |
26
|
|
|
* @param Repo $repo |
27
|
|
|
* @param ISession $session |
28
|
|
|
* @param FormFactory $formFactory |
29
|
|
|
* @param AssetManager $assetManager |
30
|
|
|
* @param IEventDispatcher $eventDispatcher |
31
|
|
|
* @param string $frontendSalt |
32
|
|
|
*/ |
33
|
|
|
public function __construct( |
34
|
|
|
FlashService $flashService, |
35
|
|
|
ITranslator $translator, |
36
|
|
|
UrlGenerator $urlGenerator, |
37
|
|
|
Repo $repo, |
38
|
|
|
ISession $session, |
39
|
|
|
FormFactory $formFactory, |
40
|
|
|
IEventDispatcher $eventDispatcher, |
41
|
|
|
AssetManager $assetManager, |
42
|
|
|
string $frontendSalt |
43
|
|
|
) { |
44
|
|
|
parent::__construct( |
45
|
|
|
$flashService, |
46
|
|
|
$translator, |
47
|
|
|
$urlGenerator, |
48
|
|
|
$repo, |
49
|
|
|
$session, |
50
|
|
|
$formFactory, |
51
|
|
|
$eventDispatcher, |
52
|
|
|
$assetManager, |
53
|
|
|
$frontendSalt |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function profile() |
58
|
|
|
{ |
59
|
|
|
$userId = $this->session->get(Session::USER_ID); |
60
|
|
|
|
61
|
|
|
$this->edit($userId); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
66
|
|
|
* |
67
|
|
|
* @param string $id |
68
|
|
|
* |
69
|
|
|
* @return string |
70
|
|
|
* @throws URLException |
71
|
|
|
*/ |
72
|
|
|
protected function getEditUrl(string $id): string |
|
|
|
|
73
|
|
|
{ |
74
|
|
|
/** @var UrlGenerator $urlGenerator */ |
75
|
|
|
$urlGenerator = $this->urlGenerator; |
76
|
|
|
|
77
|
|
|
$url = $urlGenerator->createFromName(Routes::ROUTE_PROFILE); |
78
|
|
|
|
79
|
|
|
return $url; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|