]>
Commit | Line | Data |
---|---|---|
f92fcb53 JB |
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 | * @Assert\Length(max=255) | |
41 | * @ORM\Column(name="username", type="string", length=255) | |
42 | */ | |
43 | private $username; | |
44 | ||
45 | /** | |
46 | * @var string | |
47 | * | |
48 | * @Assert\NotBlank() | |
49 | * @Assert\Length(max=255) | |
50 | * @ORM\Column(name="password", type="string", length=255) | |
51 | */ | |
52 | private $password; | |
53 | ||
54 | /** | |
55 | * @var \DateTime | |
56 | * | |
57 | * @ORM\Column(name="createdAt", type="datetime") | |
58 | */ | |
59 | private $createdAt; | |
60 | ||
61 | /** | |
62 | * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="site_credentials") | |
63 | */ | |
64 | private $user; | |
65 | ||
66 | /* | |
67 | * @param User $user | |
68 | */ | |
69 | public function __construct(User $user) | |
70 | { | |
71 | $this->user = $user; | |
72 | } | |
73 | ||
74 | /** | |
75 | * Get id. | |
76 | * | |
77 | * @return int | |
78 | */ | |
79 | public function getId() | |
80 | { | |
81 | return $this->id; | |
82 | } | |
83 | ||
84 | /** | |
85 | * Set host. | |
86 | * | |
87 | * @param string $host | |
88 | * | |
89 | * @return SiteCredential | |
90 | */ | |
91 | public function setHost($host) | |
92 | { | |
93 | $this->host = $host; | |
94 | ||
95 | return $this; | |
96 | } | |
97 | ||
98 | /** | |
99 | * Get host. | |
100 | * | |
101 | * @return string | |
102 | */ | |
103 | public function getHost() | |
104 | { | |
105 | return $this->host; | |
106 | } | |
107 | ||
108 | /** | |
109 | * Set username. | |
110 | * | |
111 | * @param string $username | |
112 | * | |
113 | * @return SiteCredential | |
114 | */ | |
115 | public function setUsername($username) | |
116 | { | |
117 | $this->username = $username; | |
118 | ||
119 | return $this; | |
120 | } | |
121 | ||
122 | /** | |
123 | * Get username. | |
124 | * | |
125 | * @return string | |
126 | */ | |
127 | public function getUsername() | |
128 | { | |
129 | return $this->username; | |
130 | } | |
131 | ||
132 | /** | |
133 | * Set password. | |
134 | * | |
135 | * @param string $password | |
136 | * | |
137 | * @return SiteCredential | |
138 | */ | |
139 | public function setPassword($password) | |
140 | { | |
141 | $this->password = $password; | |
142 | ||
143 | return $this; | |
144 | } | |
145 | ||
146 | /** | |
147 | * Get password. | |
148 | * | |
149 | * @return string | |
150 | */ | |
151 | public function getPassword() | |
152 | { | |
153 | return $this->password; | |
154 | } | |
155 | ||
156 | /** | |
157 | * Set createdAt. | |
158 | * | |
159 | * @param \DateTime $createdAt | |
160 | * | |
161 | * @return SiteCredential | |
162 | */ | |
163 | public function setCreatedAt($createdAt) | |
164 | { | |
165 | $this->createdAt = $createdAt; | |
166 | ||
167 | return $this; | |
168 | } | |
169 | ||
170 | /** | |
171 | * Get createdAt. | |
172 | * | |
173 | * @return \DateTime | |
174 | */ | |
175 | public function getCreatedAt() | |
176 | { | |
177 | return $this->createdAt; | |
178 | } | |
179 | ||
180 | /** | |
181 | * @return User | |
182 | */ | |
183 | public function getUser() | |
184 | { | |
185 | return $this->user; | |
186 | } | |
187 | ||
188 | /** | |
189 | * @ORM\PrePersist | |
190 | */ | |
191 | public function timestamps() | |
192 | { | |
193 | if (is_null($this->createdAt)) { | |
194 | $this->createdAt = new \DateTime(); | |
195 | } | |
196 | } | |
197 | } |