AuthorizeService.php 1.39 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
 * BjyAuthorize Module (https://github.com/bjyoungblood/BjyAuthorize)
 *
 * @link https://github.com/bjyoungblood/BjyAuthorize for the canonical source repository
 * @license http://framework.zend.com/license/new-bsd New BSD License
 */

namespace UnicaenAuth\Service;
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;


    public function getServiceLocator()
    {
        return $this->serviceLocator;
    }

    /**
     * @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';
        return $this->getServiceUserContext()->getSelectedIdentityRole();
    }

    /**
     * Initializes the service
     *
     * @internal
     *
     * @return void
     */
    public function load()
    {
        $this->loading = true;
        parent::load();
        $this->loading = false;
    }

}