3 namespace Wallabag\CoreBundle\Entity
;
5 use Doctrine\Common\Collections\ArrayCollection
;
6 use Doctrine\ORM\Mapping
as ORM
;
7 use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity
;
8 use Symfony\Component\Security\Core\User\UserInterface
;
9 use Symfony\Component\Security\Core\User\AdvancedUserInterface
;
10 use JMS\Serializer\Annotation\ExclusionPolicy
;
11 use JMS\Serializer\Annotation\Expose
;
12 use FOS\UserBundle\Model\User
as BaseUser
;
17 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository")
19 * @ORM\HasLifecycleCallbacks()
20 * @ExclusionPolicy("all")
22 * @UniqueEntity("email")
23 * @UniqueEntity("username")
25 class User
extends BaseUser
implements AdvancedUserInterface
, \Serializable
31 * @ORM\Column(name="id", type="integer")
33 * @ORM\GeneratedValue(strategy="AUTO")
40 * @ORM\Column(name="name", type="text", nullable=true)
47 * @ORM\Column(name="created_at", type="datetime")
54 * @ORM\Column(name="updated_at", type="datetime")
59 * @ORM\OneToMany(targetEntity="Entry", mappedBy="user", cascade={"remove"})
64 * @ORM\OneToOne(targetEntity="Config", mappedBy="user")
69 * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"})
73 public function __construct()
75 parent
::__construct();
76 $this->entries
= new ArrayCollection();
77 $this->tags
= new ArrayCollection();
84 public function timestamps()
86 if (is_null($this->createdAt
)) {
87 $this->createdAt
= new \
DateTime();
90 $this->updatedAt
= new \
DateTime();
96 * @param string $password
100 public function setPassword($password)
102 if (!$password && 0 === strlen($password)) {
106 $this->password
= sha1($password.$this->getUsername().$this->getSalt());
114 * @param string $name
118 public function setName($name)
130 public function getName()
138 public function getCreatedAt()
140 return $this->createdAt
;
146 public function getUpdatedAt()
148 return $this->updatedAt
;
152 * @param Entry $entry
156 public function addEntry(Entry
$entry)
158 $this->entries
[] = $entry;
164 * @return ArrayCollection<Entry>
166 public function getEntries()
168 return $this->entries
;
172 * @param Entry $entry
176 public function addTag(Tag
$tag)
178 $this->tags
[] = $tag;
184 * @return ArrayCollection<Tag>
186 public function getTags()
191 public function isEqualTo(UserInterface
$user)
193 return $this->username
=== $user->getUsername();
199 * @param \Wallabag\CoreBundle\Entity\Config $config
203 public function setConfig(\Wallabag\CoreBundle\Entity\Config
$config = null)
205 $this->config
= $config;
213 * @return \Wallabag\CoreBundle\Entity\Config
215 public function getConfig()
217 return $this->config
;