1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\AdminBundle\Helper\AdminPanel; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
6
|
|
|
|
7
|
|
|
class DefaultAdminPanelAdaptor implements AdminPanelAdaptorInterface |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var TokenStorageInterface |
11
|
|
|
*/ |
12
|
|
|
protected $tokenStorage; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @param TokenStorageInterface $tokenStorage |
16
|
|
|
*/ |
17
|
|
|
public function __construct(TokenStorageInterface $tokenStorage) |
18
|
|
|
{ |
19
|
|
|
$this->tokenStorage = $tokenStorage; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @return AdminPanelActionInterface[] |
|
|
|
|
24
|
|
|
*/ |
25
|
|
|
public function getAdminPanelActions() |
26
|
|
|
{ |
27
|
|
|
return array( |
28
|
|
|
$this->getLanguageChooserAction(), |
29
|
|
|
$this->getChangePasswordAction(), |
30
|
|
|
$this->getLogoutAction() |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function getLanguageChooserAction() |
35
|
|
|
{ |
36
|
|
|
return new AdminPanelAction( |
37
|
|
|
array(), |
38
|
|
|
'', |
39
|
|
|
'', |
40
|
|
|
'KunstmaanAdminBundle:AdminPanel:_language_chooser.html.twig' |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
protected function getChangePasswordAction() |
45
|
|
|
{ |
46
|
|
|
$user = $this->tokenStorage->getToken()->getUser(); |
47
|
|
|
|
48
|
|
|
return new AdminPanelAction( |
49
|
|
|
array( |
50
|
|
|
'path' => 'KunstmaanUserManagementBundle_settings_users_edit', |
51
|
|
|
'params' => array('id' => $user->getId()) |
52
|
|
|
), |
53
|
|
|
ucfirst($user->getUsername()), |
54
|
|
|
'user' |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
protected function getLogoutAction() |
59
|
|
|
{ |
60
|
|
|
return new AdminPanelAction( |
61
|
|
|
array( |
62
|
|
|
'path' => 'fos_user_security_logout', |
63
|
|
|
'attrs' => array('id' => 'app__logout', 'title' => 'logout'), |
64
|
|
|
), |
65
|
|
|
'', |
66
|
|
|
'sign-out' |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.