|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the login-cidadao project or it's bundles. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Guilherme Donato <guilhermednt on github> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace LoginCidadao\OpenIDBundle\Manager; |
|
12
|
|
|
|
|
13
|
|
|
use Doctrine\ORM\EntityManager; |
|
14
|
|
|
use LoginCidadao\OpenIDBundle\Entity\Scope; |
|
|
|
|
|
|
15
|
|
|
use OAuth2\ServerBundle\Manager\ScopeManagerInterface; |
|
16
|
|
|
use OAuth2\ServerBundle\Manager\ScopeManager as BaseManager; |
|
17
|
|
|
|
|
18
|
|
|
class ScopeManager extends BaseManager implements ScopeManagerInterface |
|
19
|
|
|
{ |
|
20
|
|
|
private $em; |
|
21
|
|
|
|
|
22
|
|
|
/** @var \OAuth2\ServerBundle\Entity\Scope[] */ |
|
23
|
|
|
private $scopes = []; |
|
24
|
|
|
|
|
25
|
4 |
|
public function __construct(EntityManager $entityManager) |
|
26
|
|
|
{ |
|
27
|
4 |
|
parent::__construct($entityManager); |
|
28
|
4 |
|
$this->em = $entityManager; |
|
29
|
4 |
|
} |
|
30
|
|
|
|
|
31
|
4 |
|
public function setScopes($scopes) |
|
32
|
|
|
{ |
|
33
|
4 |
|
if (!is_array($scopes)) { |
|
34
|
4 |
|
$scopes = explode(' ', $scopes); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
4 |
|
$this->scopes = array(); |
|
38
|
4 |
|
foreach ($scopes as $scope) { |
|
39
|
4 |
|
$scopeObj = new \OAuth2\ServerBundle\Entity\Scope(); |
|
40
|
4 |
|
$scopeObj->setScope($scope); |
|
41
|
4 |
|
$scopeObj->setDescription($scope); |
|
42
|
|
|
|
|
43
|
4 |
|
$this->scopes[$scope] = $scopeObj; |
|
44
|
|
|
} |
|
45
|
4 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Find a single scope by the scope |
|
49
|
|
|
* |
|
50
|
|
|
* @param $scope |
|
51
|
|
|
* @return \OAuth2\ServerBundle\Entity\Scope |
|
52
|
|
|
*/ |
|
53
|
3 |
|
public function findScopeByScope($scope) |
|
54
|
|
|
{ |
|
55
|
3 |
|
if (preg_match('/^tag:/', $scope) === 1) { |
|
56
|
1 |
|
$scopeObj = new \OAuth2\ServerBundle\Entity\Scope(); |
|
57
|
1 |
|
$scopeObj->setScope($scope); |
|
58
|
1 |
|
$scopeObj->setDescription($scope); |
|
59
|
|
|
|
|
60
|
1 |
|
return $scopeObj; |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
3 |
|
return $this->scopes[$scope]; |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Find all the scopes by an array of scopes |
|
68
|
|
|
* |
|
69
|
|
|
* @param array $scopes |
|
70
|
|
|
* @return \OAuth2\ServerBundle\Entity\Scope[] |
|
71
|
|
|
*/ |
|
72
|
1 |
|
public function findScopesByScopes(array $scopes) |
|
73
|
|
|
{ |
|
74
|
1 |
|
$result = array(); |
|
75
|
1 |
|
foreach ($this->scopes as $scope => $obj) { |
|
76
|
1 |
|
if (array_search($scope, $scopes) !== false) { |
|
77
|
1 |
|
$result[$scope] = $obj; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
1 |
|
return $result; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths