1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Majora\Component\OAuth\Entity; |
4
|
|
|
|
5
|
|
|
use Majora\Component\OAuth\Model\ApplicationInterface; |
6
|
|
|
use Majora\Framework\Model\CollectionableInterface; |
7
|
|
|
use Majora\Framework\Model\CollectionableTrait; |
8
|
|
|
use Majora\Framework\Serializer\Model\SerializableTrait; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Basic implementation on ApplicationInterface. |
12
|
|
|
*/ |
13
|
|
|
class Application implements ApplicationInterface, CollectionableInterface |
14
|
|
|
{ |
15
|
|
|
use CollectionableTrait, SerializableTrait; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var int |
19
|
|
|
*/ |
20
|
|
|
protected $id; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $apiKey; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
protected $secret; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $domain; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var array |
39
|
|
|
*/ |
40
|
|
|
protected $allowedScopes; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var array |
44
|
|
|
*/ |
45
|
|
|
protected $allowedGrantTypes; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var array |
49
|
|
|
*/ |
50
|
|
|
protected $roles; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var array |
54
|
|
|
*/ |
55
|
|
|
protected $accounts; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Construct. |
59
|
|
|
*/ |
60
|
12 |
|
public function __construct() |
61
|
|
|
{ |
62
|
12 |
|
$this->allowedScopes = array(); |
63
|
12 |
|
$this->allowedGrantTypes = array(); |
64
|
12 |
|
$this->roles = array(); |
65
|
12 |
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return int |
69
|
|
|
*/ |
70
|
|
|
public function getId() |
71
|
|
|
{ |
72
|
|
|
return $this->id; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @see ApplicationInterface::getApiKey() |
77
|
|
|
*/ |
78
|
|
|
public function getApiKey() |
79
|
|
|
{ |
80
|
|
|
return $this->apiKey; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Define Application apiKey value. |
85
|
|
|
* |
86
|
|
|
* @param string $apiKey |
87
|
|
|
* |
88
|
|
|
* @return self |
89
|
|
|
*/ |
90
|
|
|
public function setApiKey($apiKey) |
91
|
|
|
{ |
92
|
|
|
$this->apiKey = $apiKey; |
93
|
|
|
|
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @see ApplicationInterface::getSecret() |
99
|
|
|
*/ |
100
|
|
|
public function getSecret() |
101
|
|
|
{ |
102
|
|
|
return $this->secret; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Define Application secret value. |
107
|
|
|
* |
108
|
|
|
* @param string $secret |
109
|
|
|
* |
110
|
|
|
* @return self |
111
|
|
|
*/ |
112
|
|
|
public function setSecret($secret) |
113
|
|
|
{ |
114
|
|
|
$this->secret = $secret; |
115
|
|
|
|
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @see ApplicationInterface::getDomain() |
121
|
|
|
*/ |
122
|
|
|
public function getDomain() |
123
|
|
|
{ |
124
|
|
|
return $this->domain; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Define Application domain value. |
129
|
|
|
* |
130
|
|
|
* @param string $domain |
131
|
|
|
* |
132
|
|
|
* @return self |
133
|
|
|
*/ |
134
|
|
|
public function setDomain($domain) |
135
|
|
|
{ |
136
|
|
|
$this->domain = $domain; |
137
|
|
|
|
138
|
|
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @see ApplicationInterface::getAllowedScopes() |
143
|
|
|
*/ |
144
|
|
|
public function getAllowedScopes() |
145
|
|
|
{ |
146
|
|
|
return $this->allowedScopes; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Define Application allowedScopes value. |
151
|
|
|
* |
152
|
|
|
* @param array $allowedScopes |
153
|
|
|
* |
154
|
|
|
* @return self |
155
|
|
|
*/ |
156
|
|
|
public function setAllowedScopes(array $allowedScopes) |
157
|
|
|
{ |
158
|
|
|
$this->allowedScopes = $allowedScopes; |
159
|
|
|
|
160
|
|
|
return $this; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @see ApplicationInterface::getAllowedGrantTypes() |
165
|
|
|
*/ |
166
|
12 |
|
public function getAllowedGrantTypes() |
167
|
|
|
{ |
168
|
12 |
|
return $this->allowedGrantTypes; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Define Application allowedGrantTypes value. |
173
|
|
|
* |
174
|
|
|
* @param array $allowedGrantTypes |
175
|
|
|
* |
176
|
|
|
* @return self |
177
|
|
|
*/ |
178
|
6 |
|
public function setAllowedGrantTypes(array $allowedGrantTypes) |
179
|
|
|
{ |
180
|
6 |
|
$this->allowedGrantTypes = $allowedGrantTypes; |
181
|
|
|
|
182
|
6 |
|
return $this; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @see ApplicationInterface::getRoles() |
187
|
|
|
*/ |
188
|
|
|
public function getRoles() |
189
|
|
|
{ |
190
|
|
|
return $this->roles; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Define Application roles value. |
195
|
|
|
* |
196
|
|
|
* @param array $roles |
197
|
|
|
* |
198
|
|
|
* @return self |
199
|
|
|
*/ |
200
|
|
|
public function setRoles(array $roles) |
201
|
|
|
{ |
202
|
|
|
$this->roles = $roles; |
203
|
|
|
|
204
|
|
|
return $this; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @return array |
209
|
|
|
*/ |
210
|
|
|
public function getAccounts() |
211
|
|
|
{ |
212
|
|
|
return $this->accounts; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* @param array $accounts |
217
|
|
|
*/ |
218
|
|
|
public function setAccounts($accounts) |
219
|
|
|
{ |
220
|
|
|
$this->accounts = $accounts; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
public static function getScopes() |
224
|
|
|
{ |
225
|
|
|
return array(); |
226
|
|
|
} |
227
|
|
|
} |
228
|
|
|
|