Repository navigation
Expand file tree
/
Copy pathOAuthScope.php
More file actions
134 lines (105 loc) · 3.18 KB
/
Copy pathOAuthScope.php
File metadata and controls
134 lines (105 loc) · 3.18 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
declare(strict_types=1);
namespace Data\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use League\OAuth2\Server\Entities as OAuth;
#[ORM\Table(name: "oauth_scopes")]
#[ORM\Entity]
class OAuthScope implements OAuth\ScopeEntityInterface
{
use OAuth\Traits\ScopeTrait;
#[ORM\Column(name: "id", type: "integer", options: ["unsigned" => true])]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "IDENTITY")]
private int $id;
#[ORM\Column(length: 255)]
private string $scope;
#[ORM\ManyToMany(targetEntity: OAuthAccessToken::class, mappedBy: "scopes")]
protected Collection $accessTokens;
#[ORM\ManyToMany(targetEntity: OAuthAuthCode::class, mappedBy: "scopes")]
protected Collection $authCodes;
public function __construct()
{
$this->id = 0;
$this->scope = '';
$this->accessTokens = new ArrayCollection();
$this->authCodes = new ArrayCollection();
}
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getIdentifier(): string
{
return $this->getScope();
}
public function setScope(string $scope): self
{
$this->scope = $scope;
return $this;
}
public function getScope(): string
{
return $this->scope;
}
public function addAccessToken(OAuthAccessToken $accessToken): self
{
if ($this->accessTokens->contains($accessToken)) {
return $this;
}
$this->accessTokens->add($accessToken);
return $this;
}
public function removeAccessToken(OAuthAccessToken $accessToken): self
{
$this->accessTokens->removeElement($accessToken);
return $this;
}
/** @psalm-suppress MixedInferredReturnType */
public function getAccessTokens(?Criteria $criteria = null): Collection
{
if ($criteria === null) {
return $this->accessTokens;
}
/**
* @psalm-suppress UndefinedInterfaceMethod
* @psalm-suppress MixedReturnStatement
*/
return $this->accessTokens->matching($criteria);
}
public function addAuthCode(OAuthAuthCode $authCode): self
{
if ($this->authCodes->contains($authCode)) {
return $this;
}
$this->authCodes->add($authCode);
return $this;
}
public function removeAuthCode(OAuthAuthCode $authCode): self
{
$this->authCodes->removeElement($authCode);
/** @psalm-suppress MixedInferredReturnType */
return $this;
}
/** @psalm-suppress MixedInferredReturnType */
public function getAuthCodes(?Criteria $criteria = null): Collection
{
if ($criteria === null) {
/** @psalm-suppress MixedInferredReturnType */
return $this->authCodes;
}
/**
* @psalm-suppress UndefinedInterfaceMethod
* @psalm-suppress MixedReturnStatement
*/
return $this->authCodes->matching($criteria);
}
}