AuthorizeService.php 1.78 KB
Newer Older
1
2
3
4
<?php
/**
 * BjyAuthorize Module (https://github.com/bjyoungblood/BjyAuthorize)
 *
5
 * @link    https://github.com/bjyoungblood/BjyAuthorize for the canonical source repository
6
7
8
9
 * @license http://framework.zend.com/license/new-bsd New BSD License
 */

namespace UnicaenAuth\Service;
10

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use UnicaenAuth\Service\Traits\UserContextServiceAwareTrait;

/**
 * Authorize service
 *
 * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
 */
class AuthorizeService extends \BjyAuthorize\Service\Authorize
{
    use UserContextServiceAwareTrait;

    /**
     * Loading...
     *
     * @var boolean
     */
    protected $loading;


30

31
32
33
34
35
    public function getServiceLocator()
    {
        return $this->serviceLocator;
    }

36
37


38
39
40
41
42
43
44
45
46
47
48
    /**
     * @deprecated this method will be removed in BjyAuthorize 1.4.x+,
     *             please retrieve the identity from the
     *             `BjyAuthorize\Provider\Identity\ProviderInterface` service
     *
     * @return string
     */
    public function getIdentity()
    {
        $this->loaded && $this->loaded->__invoke();
        if ($this->loading) return 'bjyauthorize-identity';
49

50
51
52
        return $this->getServiceUserContext()->getSelectedIdentityRole();
    }

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72


    /**
     * Retourne la liste des rôles fournis par l'ensemble des providers
     */
    public function getRoles()
    {
        $roles = [];
        foreach ($this->roleProviders as $provider) {
            $r = $provider->getRoles();
            foreach ($r as $role) {
                $roles[$role->getRoleId()] = $role;
            }
        }

        return $roles;
    }



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
    /**
     * Initializes the service
     *
     * @internal
     *
     * @return void
     */
    public function load()
    {
        $this->loading = true;
        parent::load();
        $this->loading = false;
    }

}