diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/User.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/User.php | 201 |
1 files changed, 0 insertions, 201 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php deleted file mode 100644 index ae2902a3..00000000 --- a/src/Wallabag/CoreBundle/Entity/User.php +++ /dev/null | |||
@@ -1,201 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Entity; | ||
4 | |||
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 | |||
13 | /** | ||
14 | * User. | ||
15 | * | ||
16 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository") | ||
17 | * @ORM\Table | ||
18 | * @ORM\HasLifecycleCallbacks() | ||
19 | * @ExclusionPolicy("all") | ||
20 | * | ||
21 | * @UniqueEntity("email") | ||
22 | * @UniqueEntity("username") | ||
23 | */ | ||
24 | class User extends BaseUser | ||
25 | { | ||
26 | /** | ||
27 | * @var int | ||
28 | * | ||
29 | * @Expose | ||
30 | * @ORM\Column(name="id", type="integer") | ||
31 | * @ORM\Id | ||
32 | * @ORM\GeneratedValue(strategy="AUTO") | ||
33 | */ | ||
34 | protected $id; | ||
35 | |||
36 | /** | ||
37 | * @var string | ||
38 | * | ||
39 | * @ORM\Column(name="name", type="text", nullable=true) | ||
40 | */ | ||
41 | protected $name; | ||
42 | |||
43 | /** | ||
44 | * @var date | ||
45 | * | ||
46 | * @ORM\Column(name="created_at", type="datetime") | ||
47 | */ | ||
48 | protected $createdAt; | ||
49 | |||
50 | /** | ||
51 | * @var date | ||
52 | * | ||
53 | * @ORM\Column(name="updated_at", type="datetime") | ||
54 | */ | ||
55 | protected $updatedAt; | ||
56 | |||
57 | /** | ||
58 | * @ORM\OneToMany(targetEntity="Entry", mappedBy="user", cascade={"remove"}) | ||
59 | */ | ||
60 | protected $entries; | ||
61 | |||
62 | /** | ||
63 | * @ORM\OneToOne(targetEntity="Config", mappedBy="user") | ||
64 | */ | ||
65 | protected $config; | ||
66 | |||
67 | /** | ||
68 | * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"}) | ||
69 | */ | ||
70 | protected $tags; | ||
71 | |||
72 | public function __construct() | ||
73 | { | ||
74 | parent::__construct(); | ||
75 | $this->entries = new ArrayCollection(); | ||
76 | $this->tags = new ArrayCollection(); | ||
77 | $this->roles = array('ROLE_USER'); | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * @ORM\PrePersist | ||
82 | * @ORM\PreUpdate | ||
83 | */ | ||
84 | public function timestamps() | ||
85 | { | ||
86 | if (is_null($this->createdAt)) { | ||
87 | $this->createdAt = new \DateTime(); | ||
88 | } | ||
89 | |||
90 | $this->updatedAt = new \DateTime(); | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * Set name. | ||
95 | * | ||
96 | * @param string $name | ||
97 | * | ||
98 | * @return User | ||
99 | */ | ||
100 | public function setName($name) | ||
101 | { | ||
102 | $this->name = $name; | ||
103 | |||
104 | return $this; | ||
105 | } | ||
106 | |||
107 | /** | ||
108 | * Get name. | ||
109 | * | ||
110 | * @return string | ||
111 | */ | ||
112 | public function getName() | ||
113 | { | ||
114 | return $this->name; | ||
115 | } | ||
116 | |||
117 | /** | ||
118 | * @return string | ||
119 | */ | ||
120 | public function getCreatedAt() | ||
121 | { | ||
122 | return $this->createdAt; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * @return string | ||
127 | */ | ||
128 | public function getUpdatedAt() | ||
129 | { | ||
130 | return $this->updatedAt; | ||
131 | } | ||
132 | |||
133 | /** | ||
134 | * @param Entry $entry | ||
135 | * | ||
136 | * @return User | ||
137 | */ | ||
138 | public function addEntry(Entry $entry) | ||
139 | { | ||
140 | $this->entries[] = $entry; | ||
141 | |||
142 | return $this; | ||
143 | } | ||
144 | |||
145 | /** | ||
146 | * @return ArrayCollection<Entry> | ||
147 | */ | ||
148 | public function getEntries() | ||
149 | { | ||
150 | return $this->entries; | ||
151 | } | ||
152 | |||
153 | /** | ||
154 | * @param Entry $entry | ||
155 | * | ||
156 | * @return User | ||
157 | */ | ||
158 | public function addTag(Tag $tag) | ||
159 | { | ||
160 | $this->tags[] = $tag; | ||
161 | |||
162 | return $this; | ||
163 | } | ||
164 | |||
165 | /** | ||
166 | * @return ArrayCollection<Tag> | ||
167 | */ | ||
168 | public function getTags() | ||
169 | { | ||
170 | return $this->tags; | ||
171 | } | ||
172 | |||
173 | public function isEqualTo(UserInterface $user) | ||
174 | { | ||
175 | return $this->username === $user->getUsername(); | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * Set config. | ||
180 | * | ||
181 | * @param \Wallabag\CoreBundle\Entity\Config $config | ||
182 | * | ||
183 | * @return User | ||
184 | */ | ||
185 | public function setConfig(\Wallabag\CoreBundle\Entity\Config $config = null) | ||
186 | { | ||
187 | $this->config = $config; | ||
188 | |||
189 | return $this; | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * Get config. | ||
194 | * | ||
195 | * @return \Wallabag\CoreBundle\Entity\Config | ||
196 | */ | ||
197 | public function getConfig() | ||
198 | { | ||
199 | return $this->config; | ||
200 | } | ||
201 | } | ||