|
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
|
|
|
* @see NormalizableInterface::getScope() |
|
59
|
|
|
*/ |
|
60
|
|
|
public static function getScopes() |
|
61
|
|
|
{ |
|
62
|
|
|
return array( |
|
63
|
|
|
'id' => 'id', |
|
64
|
|
|
'default' => array('id', 'domain', 'allowed_scopes'), |
|
65
|
|
|
); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Construct. |
|
70
|
|
|
*/ |
|
71
|
12 |
|
public function __construct() |
|
72
|
|
|
{ |
|
73
|
12 |
|
$this->allowedScopes = array(); |
|
74
|
12 |
|
$this->allowedGrantTypes = array(); |
|
75
|
12 |
|
$this->roles = array(); |
|
76
|
12 |
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return int |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getId() |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->id; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @see ApplicationInterface::getApiKey() |
|
88
|
|
|
*/ |
|
89
|
|
|
public function getApiKey() |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->apiKey; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Define Application apiKey value. |
|
96
|
|
|
* |
|
97
|
|
|
* @param string $apiKey |
|
98
|
|
|
* |
|
99
|
|
|
* @return self |
|
100
|
|
|
*/ |
|
101
|
|
|
public function setApiKey($apiKey) |
|
102
|
|
|
{ |
|
103
|
|
|
$this->apiKey = $apiKey; |
|
104
|
|
|
|
|
105
|
|
|
return $this; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @see ApplicationInterface::getSecret() |
|
110
|
|
|
*/ |
|
111
|
|
|
public function getSecret() |
|
112
|
|
|
{ |
|
113
|
|
|
return $this->secret; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Define Application secret value. |
|
118
|
|
|
* |
|
119
|
|
|
* @param string $secret |
|
120
|
|
|
* |
|
121
|
|
|
* @return self |
|
122
|
|
|
*/ |
|
123
|
|
|
public function setSecret($secret) |
|
124
|
|
|
{ |
|
125
|
|
|
$this->secret = $secret; |
|
126
|
|
|
|
|
127
|
|
|
return $this; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @see ApplicationInterface::getDomain() |
|
132
|
|
|
*/ |
|
133
|
|
|
public function getDomain() |
|
134
|
|
|
{ |
|
135
|
|
|
return $this->domain; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Define Application domain value. |
|
140
|
|
|
* |
|
141
|
|
|
* @param string $domain |
|
142
|
|
|
* |
|
143
|
|
|
* @return self |
|
144
|
|
|
*/ |
|
145
|
|
|
public function setDomain($domain) |
|
146
|
|
|
{ |
|
147
|
|
|
$this->domain = $domain; |
|
148
|
|
|
|
|
149
|
|
|
return $this; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* @see ApplicationInterface::getAllowedScopes() |
|
154
|
|
|
*/ |
|
155
|
|
|
public function getAllowedScopes() |
|
156
|
|
|
{ |
|
157
|
|
|
return $this->allowedScopes; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* Define Application allowedScopes value. |
|
162
|
|
|
* |
|
163
|
|
|
* @param array $allowedScopes |
|
164
|
|
|
* |
|
165
|
|
|
* @return self |
|
166
|
|
|
*/ |
|
167
|
|
|
public function setAllowedScopes(array $allowedScopes) |
|
168
|
|
|
{ |
|
169
|
|
|
$this->allowedScopes = $allowedScopes; |
|
170
|
|
|
|
|
171
|
|
|
return $this; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* @see ApplicationInterface::getAllowedGrantTypes() |
|
176
|
|
|
*/ |
|
177
|
12 |
|
public function getAllowedGrantTypes() |
|
178
|
|
|
{ |
|
179
|
12 |
|
return $this->allowedGrantTypes; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* Define Application allowedGrantTypes value. |
|
184
|
|
|
* |
|
185
|
|
|
* @param array $allowedGrantTypes |
|
186
|
|
|
* |
|
187
|
|
|
* @return self |
|
188
|
|
|
*/ |
|
189
|
6 |
|
public function setAllowedGrantTypes(array $allowedGrantTypes) |
|
190
|
|
|
{ |
|
191
|
6 |
|
$this->allowedGrantTypes = $allowedGrantTypes; |
|
192
|
|
|
|
|
193
|
6 |
|
return $this; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* @see ApplicationInterface::getRoles() |
|
198
|
|
|
*/ |
|
199
|
|
|
public function getRoles() |
|
200
|
|
|
{ |
|
201
|
|
|
return $this->roles; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* Define Application roles value. |
|
206
|
|
|
* |
|
207
|
|
|
* @param array $roles |
|
208
|
|
|
* |
|
209
|
|
|
* @return self |
|
210
|
|
|
*/ |
|
211
|
|
|
public function setRoles(array $roles) |
|
212
|
|
|
{ |
|
213
|
|
|
$this->roles = $roles; |
|
214
|
|
|
|
|
215
|
|
|
return $this; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* @return array |
|
220
|
|
|
*/ |
|
221
|
|
|
public function getAccounts() |
|
222
|
|
|
{ |
|
223
|
|
|
return $this->accounts; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* @param array $accounts |
|
228
|
|
|
*/ |
|
229
|
|
|
public function setAccounts($accounts) |
|
230
|
|
|
{ |
|
231
|
|
|
$this->accounts = $accounts; |
|
232
|
|
|
} |
|
233
|
|
|
} |
|
234
|
|
|
|