3 namespace Wallabag\CoreBundle\Entity
;
5 use Doctrine\Common\Collections\ArrayCollection
;
6 use Doctrine\ORM\Mapping
as ORM
;
7 use Symfony\Component\Security\Core\User\UserInterface
;
8 use Symfony\Component\Security\Core\User\AdvancedUserInterface
;
13 * @ORM\Table(name="user")
15 * @ORM\HasLifecycleCallbacks()
17 class User
implements AdvancedUserInterface
, \Serializable
22 * @ORM\Column(name="id", type="integer")
24 * @ORM\GeneratedValue(strategy="AUTO")
31 * @ORM\Column(name="username", type="text")
38 * @ORM\Column(type="string", length=32)
45 * @ORM\Column(name="password", type="text")
52 * @ORM\Column(name="name", type="text", nullable=true)
59 * @ORM\Column(name="email", type="text", nullable=true)
64 * @ORM\Column(name="is_active", type="boolean")
71 * @ORM\Column(name="created_at", type="datetime")
78 * @ORM\Column(name="updated_at", type="datetime")
83 * @ORM\OneToMany(targetEntity="Entry", mappedBy="user", cascade={"remove"})
87 public function __construct()
89 $this->isActive
= true;
90 $this->salt
= md5(uniqid(null, true));
91 $this->entries
= new ArrayCollection();
98 public function timestamps()
100 if (is_null($this->createdAt
)) {
101 $this->createdAt
= new \
DateTime();
104 $this->updatedAt
= new \
DateTime();
112 public function getId()
120 * @param string $username
123 public function setUsername($username)
125 $this->username
= $username;
135 public function getUsername()
137 return $this->username
;
143 public function getSalt()
151 public function getRoles()
153 return array('ROLE_USER');
159 * @param string $password
162 public function setPassword($password)
164 $this->password
= $password;
174 public function getPassword()
176 return $this->password
;
182 * @param string $name
185 public function setName($name)
197 public function getName()
205 * @param string $email
208 public function setEmail($email)
210 $this->email
= $email;
220 public function getEmail()
228 public function getCreatedAt()
230 return $this->createdAt
;
236 public function getUpdatedAt()
238 return $this->updatedAt
;
242 * @param Entry $entry
246 public function addEntry(Entry
$entry)
248 $this->entries
[] = $entry;
254 * @return ArrayCollection<Entry>
256 public function getEntries()
258 return $this->entries
;
264 public function eraseCredentials()
269 * @see \Serializable::serialize()
271 public function serialize()
273 return serialize(array(
279 * @see \Serializable::unserialize()
281 public function unserialize($serialized)
285 ) = unserialize($serialized);
288 public function isEqualTo(UserInterface
$user)
290 return $this->username
=== $user->getUsername();
293 public function isAccountNonExpired()
298 public function isAccountNonLocked()
303 public function isCredentialsNonExpired()
308 public function isEnabled()
310 return $this->isActive
;