|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AppBundle\Legacy\User; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
|
6
|
|
|
|
|
7
|
|
|
class LegacyUser implements UserInterface |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @var integer |
|
11
|
|
|
*/ |
|
12
|
|
|
protected $id; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var string |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $userName; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* LegacyUser constructor. |
|
21
|
|
|
* |
|
22
|
|
|
* @param int $id |
|
23
|
|
|
* @param string $userName |
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct($id, $userName) |
|
26
|
|
|
{ |
|
27
|
|
|
$this->id = $id; |
|
28
|
|
|
$this->userName = $userName; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Returns the roles granted to the user. |
|
33
|
|
|
* |
|
34
|
|
|
* <code> |
|
35
|
|
|
* public function getRoles() |
|
36
|
|
|
* { |
|
37
|
|
|
* return array('ROLE_USER'); |
|
38
|
|
|
* } |
|
39
|
|
|
* </code> |
|
40
|
|
|
* |
|
41
|
|
|
* Alternatively, the roles might be stored on a ``roles`` property, |
|
42
|
|
|
* and populated in any number of different ways when the user object |
|
43
|
|
|
* is created. |
|
44
|
|
|
* |
|
45
|
|
|
* @return array The user roles |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getRoles() |
|
48
|
|
|
{ |
|
49
|
|
|
if (!$this->id) { |
|
50
|
|
|
return []; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
return ['ROLE_USER']; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Returns the password used to authenticate the user. |
|
58
|
|
|
* |
|
59
|
|
|
* This should be the encoded password. On authentication, a plain-text |
|
60
|
|
|
* password will be salted, encoded, and then compared to this value. |
|
61
|
|
|
* |
|
62
|
|
|
* @return string The password |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getPassword() |
|
65
|
|
|
{ |
|
66
|
|
|
// TODO: Implement getPassword() method. |
|
67
|
|
|
return ''; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Returns the salt that was originally used to encode the password. |
|
72
|
|
|
* |
|
73
|
|
|
* This can return null if the password was not encoded using a salt. |
|
74
|
|
|
* |
|
75
|
|
|
* @return string|null The salt |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getSalt() |
|
78
|
|
|
{ |
|
79
|
|
|
// TODO: Implement getSalt() method. |
|
80
|
|
|
return ''; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return int |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getId() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->id; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Returns the username used to authenticate the user. |
|
93
|
|
|
* |
|
94
|
|
|
* @return string The username |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getUsername() |
|
97
|
|
|
{ |
|
98
|
|
|
// TODO: Implement getUsername() method. |
|
99
|
|
|
return $this->userName; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Removes sensitive data from the user. |
|
104
|
|
|
* |
|
105
|
|
|
* This is important if, at any given point, sensitive information like |
|
106
|
|
|
* the plain-text password is stored on this object. |
|
107
|
|
|
* @return void |
|
108
|
|
|
*/ |
|
109
|
|
|
public function eraseCredentials() |
|
110
|
|
|
{ |
|
111
|
|
|
// TODO: Implement eraseCredentials() method. |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param string $userName |
|
116
|
|
|
* |
|
117
|
|
|
* @return \AppBundle\Legacy\User\LegacyUser |
|
118
|
|
|
*/ |
|
119
|
|
|
public function setUserName($userName) |
|
120
|
|
|
{ |
|
121
|
|
|
$this->userName = $userName; |
|
122
|
|
|
|
|
123
|
|
|
return $this; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @param int $id |
|
128
|
|
|
* |
|
129
|
|
|
* @return \AppBundle\Legacy\User\LegacyUser |
|
130
|
|
|
*/ |
|
131
|
|
|
public function setId($id) |
|
132
|
|
|
{ |
|
133
|
|
|
$this->id = $id; |
|
134
|
|
|
|
|
135
|
|
|
return $this; |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|