Completed
Push — master ( 91fdab...75a7b9 )
by
unknown
13:37
created

Helper/AdminPanel/DefaultAdminPanelAdaptor.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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[]
0 ignored issues
show
Consider making the return type a bit more specific; maybe use AdminPanelAction[].

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.

Loading history...
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