diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Config.php | 10 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entry.php | 5 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Tag.php | 4 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/User.php | 219 |
4 files changed, 10 insertions, 228 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index 025d94ef..2390bfe1 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php | |||
@@ -72,14 +72,14 @@ class Config | |||
72 | private $rssLimit; | 72 | private $rssLimit; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * @ORM\OneToOne(targetEntity="User", inversedBy="config") | 75 | * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config") |
76 | */ | 76 | */ |
77 | private $user; | 77 | private $user; |
78 | 78 | ||
79 | /* | 79 | /* |
80 | * @param User $user | 80 | * @param User $user |
81 | */ | 81 | */ |
82 | public function __construct(User $user) | 82 | public function __construct(\Wallabag\UserBundle\Entity\User $user) |
83 | { | 83 | { |
84 | $this->user = $user; | 84 | $this->user = $user; |
85 | } | 85 | } |
@@ -169,11 +169,11 @@ class Config | |||
169 | /** | 169 | /** |
170 | * Set user. | 170 | * Set user. |
171 | * | 171 | * |
172 | * @param \Wallabag\CoreBundle\Entity\User $user | 172 | * @param User $user |
173 | * | 173 | * |
174 | * @return Config | 174 | * @return Config |
175 | */ | 175 | */ |
176 | public function setUser(\Wallabag\CoreBundle\Entity\User $user = null) | 176 | public function setUser(User $user = null) |
177 | { | 177 | { |
178 | $this->user = $user; | 178 | $this->user = $user; |
179 | 179 | ||
@@ -183,7 +183,7 @@ class Config | |||
183 | /** | 183 | /** |
184 | * Get user. | 184 | * Get user. |
185 | * | 185 | * |
186 | * @return \Wallabag\CoreBundle\Entity\User | 186 | * @return User |
187 | */ | 187 | */ |
188 | public function getUser() | 188 | public function getUser() |
189 | { | 189 | { |
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 9e81ba12..4fd74001 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -7,6 +7,7 @@ use Doctrine\ORM\Mapping as ORM; | |||
7 | use Symfony\Component\Validator\Constraints as Assert; | 7 | use Symfony\Component\Validator\Constraints as Assert; |
8 | use Hateoas\Configuration\Annotation as Hateoas; | 8 | use Hateoas\Configuration\Annotation as Hateoas; |
9 | use JMS\Serializer\Annotation\XmlRoot; | 9 | use JMS\Serializer\Annotation\XmlRoot; |
10 | use Wallabag\UserBundle\Entity\User; | ||
10 | 11 | ||
11 | /** | 12 | /** |
12 | * Entry. | 13 | * Entry. |
@@ -129,7 +130,7 @@ class Entry | |||
129 | private $isPublic; | 130 | private $isPublic; |
130 | 131 | ||
131 | /** | 132 | /** |
132 | * @ORM\ManyToOne(targetEntity="User", inversedBy="entries") | 133 | * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="entries") |
133 | */ | 134 | */ |
134 | private $user; | 135 | private $user; |
135 | 136 | ||
@@ -142,7 +143,7 @@ class Entry | |||
142 | /* | 143 | /* |
143 | * @param User $user | 144 | * @param User $user |
144 | */ | 145 | */ |
145 | public function __construct(User $user) | 146 | public function __construct(\Wallabag\UserBundle\Entity\User $user) |
146 | { | 147 | { |
147 | $this->user = $user; | 148 | $this->user = $user; |
148 | $this->tags = new ArrayCollection(); | 149 | $this->tags = new ArrayCollection(); |
diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php index 97c4579f..5b571823 100644 --- a/src/Wallabag/CoreBundle/Entity/Tag.php +++ b/src/Wallabag/CoreBundle/Entity/Tag.php | |||
@@ -42,11 +42,11 @@ class Tag | |||
42 | private $entries; | 42 | private $entries; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * @ORM\ManyToOne(targetEntity="User", inversedBy="tags") | 45 | * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="tags") |
46 | */ | 46 | */ |
47 | private $user; | 47 | private $user; |
48 | 48 | ||
49 | public function __construct(User $user) | 49 | public function __construct(\Wallabag\UserBundle\Entity\User $user) |
50 | { | 50 | { |
51 | $this->user = $user; | 51 | $this->user = $user; |
52 | $this->entries = new ArrayCollection(); | 52 | $this->entries = new ArrayCollection(); |
diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php deleted file mode 100644 index a6002352..00000000 --- a/src/Wallabag/CoreBundle/Entity/User.php +++ /dev/null | |||
@@ -1,219 +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 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; | ||
13 | |||
14 | /** | ||
15 | * User. | ||
16 | * | ||
17 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository") | ||
18 | * @ORM\Table | ||
19 | * @ORM\HasLifecycleCallbacks() | ||
20 | * @ExclusionPolicy("all") | ||
21 | * | ||
22 | * @UniqueEntity("email") | ||
23 | * @UniqueEntity("username") | ||
24 | */ | ||
25 | class User extends BaseUser implements AdvancedUserInterface, \Serializable | ||
26 | { | ||
27 | /** | ||
28 | * @var int | ||
29 | * | ||
30 | * @Expose | ||
31 | * @ORM\Column(name="id", type="integer") | ||
32 | * @ORM\Id | ||
33 | * @ORM\GeneratedValue(strategy="AUTO") | ||
34 | */ | ||
35 | protected $id; | ||
36 | |||
37 | /** | ||
38 | * @var string | ||
39 | * | ||
40 | * @ORM\Column(name="name", type="text", nullable=true) | ||
41 | */ | ||
42 | protected $name; | ||
43 | |||
44 | /** | ||
45 | * @var date | ||
46 | * | ||
47 | * @ORM\Column(name="created_at", type="datetime") | ||
48 | */ | ||
49 | protected $createdAt; | ||
50 | |||
51 | /** | ||
52 | * @var date | ||
53 | * | ||
54 | * @ORM\Column(name="updated_at", type="datetime") | ||
55 | */ | ||
56 | protected $updatedAt; | ||
57 | |||
58 | /** | ||
59 | * @ORM\OneToMany(targetEntity="Entry", mappedBy="user", cascade={"remove"}) | ||
60 | */ | ||
61 | protected $entries; | ||
62 | |||
63 | /** | ||
64 | * @ORM\OneToOne(targetEntity="Config", mappedBy="user") | ||
65 | */ | ||
66 | protected $config; | ||
67 | |||
68 | /** | ||
69 | * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"}) | ||
70 | */ | ||
71 | protected $tags; | ||
72 | |||
73 | public function __construct() | ||
74 | { | ||
75 | parent::__construct(); | ||
76 | $this->entries = new ArrayCollection(); | ||
77 | $this->tags = new ArrayCollection(); | ||
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 password. | ||
95 | * | ||
96 | * @param string $password | ||
97 | * | ||
98 | * @return User | ||
99 | */ | ||
100 | public function setPassword($password) | ||
101 | { | ||
102 | if (!$password && 0 === strlen($password)) { | ||
103 | return; | ||
104 | } | ||
105 | |||
106 | $this->password = sha1($password.$this->getUsername().$this->getSalt()); | ||
107 | |||
108 | return $this; | ||
109 | } | ||
110 | |||
111 | /** | ||
112 | * Set name. | ||
113 | * | ||
114 | * @param string $name | ||
115 | * | ||
116 | * @return User | ||
117 | */ | ||
118 | public function setName($name) | ||
119 | { | ||
120 | $this->name = $name; | ||
121 | |||
122 | return $this; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * Get name. | ||
127 | * | ||
128 | * @return string | ||
129 | */ | ||
130 | public function getName() | ||
131 | { | ||
132 | return $this->name; | ||
133 | } | ||
134 | |||
135 | /** | ||
136 | * @return string | ||
137 | */ | ||
138 | public function getCreatedAt() | ||
139 | { | ||
140 | return $this->createdAt; | ||
141 | } | ||
142 | |||
143 | /** | ||
144 | * @return string | ||
145 | */ | ||
146 | public function getUpdatedAt() | ||
147 | { | ||
148 | return $this->updatedAt; | ||
149 | } | ||
150 | |||
151 | /** | ||
152 | * @param Entry $entry | ||
153 | * | ||
154 | * @return User | ||
155 | */ | ||
156 | public function addEntry(Entry $entry) | ||
157 | { | ||
158 | $this->entries[] = $entry; | ||
159 | |||
160 | return $this; | ||
161 | } | ||
162 | |||
163 | /** | ||
164 | * @return ArrayCollection<Entry> | ||
165 | */ | ||
166 | public function getEntries() | ||
167 | { | ||
168 | return $this->entries; | ||
169 | } | ||
170 | |||
171 | /** | ||
172 | * @param Entry $entry | ||
173 | * | ||
174 | * @return User | ||
175 | */ | ||
176 | public function addTag(Tag $tag) | ||
177 | { | ||
178 | $this->tags[] = $tag; | ||
179 | |||
180 | return $this; | ||
181 | } | ||
182 | |||
183 | /** | ||
184 | * @return ArrayCollection<Tag> | ||
185 | */ | ||
186 | public function getTags() | ||
187 | { | ||
188 | return $this->tags; | ||
189 | } | ||
190 | |||
191 | public function isEqualTo(UserInterface $user) | ||
192 | { | ||
193 | return $this->username === $user->getUsername(); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Set config. | ||
198 | * | ||
199 | * @param \Wallabag\CoreBundle\Entity\Config $config | ||
200 | * | ||
201 | * @return User | ||
202 | */ | ||
203 | public function setConfig(\Wallabag\CoreBundle\Entity\Config $config = null) | ||
204 | { | ||
205 | $this->config = $config; | ||
206 | |||
207 | return $this; | ||
208 | } | ||
209 | |||
210 | /** | ||
211 | * Get config. | ||
212 | * | ||
213 | * @return \Wallabag\CoreBundle\Entity\Config | ||
214 | */ | ||
215 | public function getConfig() | ||
216 | { | ||
217 | return $this->config; | ||
218 | } | ||
219 | } | ||