1 | <?php |
||
13 | abstract class AbstractToken extends AbstractEntity implements ScopesProviderInterface |
||
14 | { |
||
15 | use ScopesProviderTrait; |
||
16 | use ExpiryDateProviderTrait; |
||
17 | |||
18 | /** |
||
19 | * The token string; must be unique |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $token; |
||
24 | |||
25 | /** |
||
26 | * A token always belongs to a particular client |
||
27 | * |
||
28 | * @var Client |
||
29 | */ |
||
30 | protected $client; |
||
31 | |||
32 | /** |
||
33 | * A token may belong to a particular user |
||
34 | * |
||
35 | * @var UserInterface |
||
36 | */ |
||
37 | protected $user; |
||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | * |
||
42 | * @param string $token |
||
43 | * @param Client $client |
||
44 | * @param UserInterface $user |
||
45 | * @param array|Collection $scopes |
||
46 | */ |
||
47 | public function __construct($uuid = null, $token, Client $client, UserInterface $user = null, $scopes = null) |
||
48 | { |
||
49 | parent::__construct($uuid); |
||
50 | |||
51 | $this->setToken($token); |
||
52 | $this->setClient($client); |
||
53 | |||
54 | if ($user) { |
||
55 | $this->setUser($user); |
||
56 | } |
||
57 | |||
58 | if ($scopes) { |
||
59 | $this->setScopes($scopes); |
||
60 | } else { |
||
61 | $this->initScopes(); |
||
62 | } |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @param Client $client |
||
67 | */ |
||
68 | public function setClient(Client $client) |
||
72 | |||
73 | /** |
||
74 | * @return Client |
||
75 | */ |
||
76 | public function getClient() |
||
80 | |||
81 | /** |
||
82 | * @param string $token |
||
83 | */ |
||
84 | public function setToken($token) |
||
88 | |||
89 | /** |
||
90 | * @return string |
||
91 | */ |
||
92 | public function getToken() |
||
93 | { |
||
94 | return $this->token; |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * @param UserInterface $user |
||
99 | */ |
||
100 | public function setUser(UserInterface $user = null) |
||
104 | |||
105 | /** |
||
106 | * @return UserInterface|null |
||
107 | */ |
||
108 | public function getUser() |
||
112 | } |
||
113 |