diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-06-20 16:40:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-20 16:40:48 +0200 |
commit | 80784b782becfaa297e6d9cbb0584e27739cffc8 (patch) | |
tree | fc201969597b16070d890b0703568618a81a76bc /src/Wallabag/CoreBundle/Entity/SiteCredential.php | |
parent | 604cca1f4247f9f905e57b9276cf2543cfa41a5d (diff) | |
parent | f44dba22fc1a566cb156d9e6eda5afc353163eda (diff) | |
download | wallabag-80784b782becfaa297e6d9cbb0584e27739cffc8.tar.gz wallabag-80784b782becfaa297e6d9cbb0584e27739cffc8.tar.zst wallabag-80784b782becfaa297e6d9cbb0584e27739cffc8.zip |
Merge pull request #2683 from wallabag/credentials-in-db
Store credentials in DB
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/SiteCredential.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/SiteCredential.php | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/SiteCredential.php b/src/Wallabag/CoreBundle/Entity/SiteCredential.php new file mode 100644 index 00000000..58075e92 --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/SiteCredential.php | |||
@@ -0,0 +1,195 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Entity; | ||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; | ||
6 | use Symfony\Component\Validator\Constraints as Assert; | ||
7 | use Wallabag\UserBundle\Entity\User; | ||
8 | |||
9 | /** | ||
10 | * SiteCredential. | ||
11 | * | ||
12 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\SiteCredentialRepository") | ||
13 | * @ORM\Table(name="`site_credential`") | ||
14 | * @ORM\HasLifecycleCallbacks() | ||
15 | */ | ||
16 | class SiteCredential | ||
17 | { | ||
18 | /** | ||
19 | * @var int | ||
20 | * | ||
21 | * @ORM\Column(name="id", type="integer") | ||
22 | * @ORM\Id | ||
23 | * @ORM\GeneratedValue(strategy="AUTO") | ||
24 | */ | ||
25 | private $id; | ||
26 | |||
27 | /** | ||
28 | * @var string | ||
29 | * | ||
30 | * @Assert\NotBlank() | ||
31 | * @Assert\Length(max=255) | ||
32 | * @ORM\Column(name="host", type="string", length=255) | ||
33 | */ | ||
34 | private $host; | ||
35 | |||
36 | /** | ||
37 | * @var string | ||
38 | * | ||
39 | * @Assert\NotBlank() | ||
40 | * @ORM\Column(name="username", type="text") | ||
41 | */ | ||
42 | private $username; | ||
43 | |||
44 | /** | ||
45 | * @var string | ||
46 | * | ||
47 | * @Assert\NotBlank() | ||
48 | * @ORM\Column(name="password", type="text") | ||
49 | */ | ||
50 | private $password; | ||
51 | |||
52 | /** | ||
53 | * @var \DateTime | ||
54 | * | ||
55 | * @ORM\Column(name="createdAt", type="datetime") | ||
56 | */ | ||
57 | private $createdAt; | ||
58 | |||
59 | /** | ||
60 | * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="site_credentials") | ||
61 | */ | ||
62 | private $user; | ||
63 | |||
64 | /* | ||
65 | * @param User $user | ||
66 | */ | ||
67 | public function __construct(User $user) | ||
68 | { | ||
69 | $this->user = $user; | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * Get id. | ||
74 | * | ||
75 | * @return int | ||
76 | */ | ||
77 | public function getId() | ||
78 | { | ||
79 | return $this->id; | ||
80 | } | ||
81 | |||
82 | /** | ||
83 | * Set host. | ||
84 | * | ||
85 | * @param string $host | ||
86 | * | ||
87 | * @return SiteCredential | ||
88 | */ | ||
89 | public function setHost($host) | ||
90 | { | ||
91 | $this->host = $host; | ||
92 | |||
93 | return $this; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * Get host. | ||
98 | * | ||
99 | * @return string | ||
100 | */ | ||
101 | public function getHost() | ||
102 | { | ||
103 | return $this->host; | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * Set username. | ||
108 | * | ||
109 | * @param string $username | ||
110 | * | ||
111 | * @return SiteCredential | ||
112 | */ | ||
113 | public function setUsername($username) | ||
114 | { | ||
115 | $this->username = $username; | ||
116 | |||
117 | return $this; | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * Get username. | ||
122 | * | ||
123 | * @return string | ||
124 | */ | ||
125 | public function getUsername() | ||
126 | { | ||
127 | return $this->username; | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * Set password. | ||
132 | * | ||
133 | * @param string $password | ||
134 | * | ||
135 | * @return SiteCredential | ||
136 | */ | ||
137 | public function setPassword($password) | ||
138 | { | ||
139 | $this->password = $password; | ||
140 | |||
141 | return $this; | ||
142 | } | ||
143 | |||
144 | /** | ||
145 | * Get password. | ||
146 | * | ||
147 | * @return string | ||
148 | */ | ||
149 | public function getPassword() | ||
150 | { | ||
151 | return $this->password; | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * Set createdAt. | ||
156 | * | ||
157 | * @param \DateTime $createdAt | ||
158 | * | ||
159 | * @return SiteCredential | ||
160 | */ | ||
161 | public function setCreatedAt($createdAt) | ||
162 | { | ||
163 | $this->createdAt = $createdAt; | ||
164 | |||
165 | return $this; | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * Get createdAt. | ||
170 | * | ||
171 | * @return \DateTime | ||
172 | */ | ||
173 | public function getCreatedAt() | ||
174 | { | ||
175 | return $this->createdAt; | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * @return User | ||
180 | */ | ||
181 | public function getUser() | ||
182 | { | ||
183 | return $this->user; | ||
184 | } | ||
185 | |||
186 | /** | ||
187 | * @ORM\PrePersist | ||
188 | */ | ||
189 | public function timestamps() | ||
190 | { | ||
191 | if (is_null($this->createdAt)) { | ||
192 | $this->createdAt = new \DateTime(); | ||
193 | } | ||
194 | } | ||
195 | } | ||