Completed
Push — master ( ae5e03...0447ee )
by Jeroen
10:35 queued 04: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 1
    public function __construct(TokenStorageInterface $tokenStorage)
18
    {
19 1
        $this->tokenStorage = $tokenStorage;
20 1
    }
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 1
    public function getAdminPanelActions()
26
    {
27
        return array(
28 1
            $this->getLanguageChooserAction(),
29 1
            $this->getChangePasswordAction(),
30 1
            $this->getLogoutAction(),
31
        );
32
    }
33
34 1
    protected function getLanguageChooserAction()
35
    {
36 1
        return new AdminPanelAction(
37 1
            array(),
38 1
            '',
39 1
            '',
40 1
            '@KunstmaanAdmin/AdminPanel/_language_chooser.html.twig'
41
        );
42
    }
43
44 1
    protected function getChangePasswordAction()
45
    {
46 1
        $user = $this->tokenStorage->getToken()->getUser();
47
48 1
        return new AdminPanelAction(
49
            array(
50 1
                'path' => 'KunstmaanUserManagementBundle_settings_users_edit',
51 1
                'params' => array('id' => $user->getId()),
52
            ),
53 1
            ucfirst($user->getUsername()),
54 1
            'user'
55
        );
56
    }
57
58 1
    protected function getLogoutAction()
59
    {
60 1
        return new AdminPanelAction(
61
            array(
62 1
                'path' => 'fos_user_security_logout',
63
                'attrs' => array('id' => 'app__logout', 'title' => 'logout'),
64
            ),
65 1
            '',
66 1
            'sign-out'
67
        );
68
    }
69
}
70