3 namespace Wallabag\UserBundle\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 JMS\Serializer\Annotation\ExclusionPolicy
;
10 use JMS\Serializer\Annotation\Expose
;
11 use FOS\UserBundle\Model\User
as BaseUser
;
12 use Wallabag\CoreBundle\Entity\Config
;
13 use Wallabag\CoreBundle\Entity\Entry
;
14 use Wallabag\CoreBundle\Entity\Tag
;
19 * @ORM\Entity(repositoryClass="Wallabag\UserBundle\Repository\UserRepository")
21 * @ORM\HasLifecycleCallbacks()
22 * @ExclusionPolicy("all")
24 * @UniqueEntity("email")
25 * @UniqueEntity("username")
27 class User
extends BaseUser
33 * @ORM\Column(name="id", type="integer")
35 * @ORM\GeneratedValue(strategy="AUTO")
42 * @ORM\Column(name="name", type="text", nullable=true)
49 * @ORM\Column(name="created_at", type="datetime")
56 * @ORM\Column(name="updated_at", type="datetime")
61 * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\Entry", mappedBy="user", cascade={"remove"})
66 * @ORM\OneToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", mappedBy="user")
71 * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\Tag", mappedBy="user", cascade={"remove"})
75 public function __construct()
77 parent
::__construct();
78 $this->entries
= new ArrayCollection();
79 $this->tags
= new ArrayCollection();
80 $this->roles
= array('ROLE_USER');
87 public function timestamps()
89 if (is_null($this->createdAt
)) {
90 $this->createdAt
= new \
DateTime();
93 $this->updatedAt
= new \
DateTime();
103 public function setName($name)
115 public function getName()
123 public function getCreatedAt()
125 return $this->createdAt
;
131 public function getUpdatedAt()
133 return $this->updatedAt
;
137 * @param Entry $entry
141 public function addEntry(Entry
$entry)
143 $this->entries
[] = $entry;
149 * @return ArrayCollection<Entry>
151 public function getEntries()
153 return $this->entries
;
157 * @param Entry $entry
161 public function addTag(Tag
$tag)
163 $this->tags
[] = $tag;
169 * @return ArrayCollection<Tag>
171 public function getTags()
176 public function isEqualTo(UserInterface
$user)
178 return $this->username
=== $user->getUsername();
184 * @param Config $config
188 public function setConfig(Config
$config = null)
190 $this->config
= $config;
200 public function getConfig()
202 return $this->config
;