aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CommentBundle/Entity
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-02-07 16:52:59 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-02-26 18:13:17 +0100
commitf38e03dc02c96344677fd2720912605b21c90b5d (patch)
tree2028cecf5d0930e1569ddb977e245ea44bedc38a /src/Wallabag/CommentBundle/Entity
parentd3f1a9dc1ac181033ec54f9149d2807199fa8f17 (diff)
downloadwallabag-f38e03dc02c96344677fd2720912605b21c90b5d.tar.gz
wallabag-f38e03dc02c96344677fd2720912605b21c90b5d.tar.zst
wallabag-f38e03dc02c96344677fd2720912605b21c90b5d.zip
Comment work with annotator v2
- add missing annotator.js file and fix typo - edit & delete routes, started tests - basic tests
Diffstat (limited to 'src/Wallabag/CommentBundle/Entity')
-rw-r--r--src/Wallabag/CommentBundle/Entity/Comment.php270
1 files changed, 270 insertions, 0 deletions
diff --git a/src/Wallabag/CommentBundle/Entity/Comment.php b/src/Wallabag/CommentBundle/Entity/Comment.php
new file mode 100644
index 00000000..a89a2cb3
--- /dev/null
+++ b/src/Wallabag/CommentBundle/Entity/Comment.php
@@ -0,0 +1,270 @@
1<?php
2
3namespace Wallabag\CommentBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6use JMS\Serializer\Annotation\ExclusionPolicy;
7use JMS\Serializer\Annotation\Exclude;
8use JMS\Serializer\Annotation\VirtualProperty;
9use JMS\Serializer\Annotation\SerializedName;
10use Wallabag\UserBundle\Entity\User;
11use Wallabag\CoreBundle\Entity\Entry;
12
13/**
14 * Comment.
15 *
16 * @ORM\Table(name="comment")
17 * @ORM\Entity(repositoryClass="Wallabag\CommentBundle\Repository\CommentRepository")
18 * @ORM\HasLifecycleCallbacks()
19 * @ExclusionPolicy("none")
20 */
21class Comment
22{
23 /**
24 * @var int
25 *
26 * @ORM\Column(name="id", type="integer")
27 * @ORM\Id
28 * @ORM\GeneratedValue(strategy="AUTO")
29 */
30 private $id;
31
32 /**
33 * @var string
34 *
35 * @ORM\Column(name="text", type="text")
36 */
37 private $text;
38
39 /**
40 * @var \DateTime
41 *
42 * @ORM\Column(name="created_at", type="datetime")
43 */
44 private $createdAt;
45
46 /**
47 * @var \DateTime
48 *
49 * @ORM\Column(name="updated_at", type="datetime")
50 */
51 private $updatedAt;
52
53 /**
54 * @var string
55 *
56 * @ORM\Column(name="quote", type="string")
57 */
58 private $quote;
59
60 /**
61 * @var array
62 *
63 * @ORM\Column(name="ranges", type="array")
64 */
65 private $ranges;
66
67 /**
68 * @Exclude
69 *
70 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User")
71 */
72 private $user;
73
74 /**
75 * @Exclude
76 *
77 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry", inversedBy="comments")
78 * @ORM\JoinColumn(name="entry_id", referencedColumnName="id")
79 */
80 private $entry;
81
82 /*
83 * @param User $user
84 */
85 public function __construct(\Wallabag\UserBundle\Entity\User $user)
86 {
87 $this->user = $user;
88 }
89
90 /**
91 * Get id.
92 *
93 * @return int
94 */
95 public function getId()
96 {
97 return $this->id;
98 }
99
100 /**
101 * Set text.
102 *
103 * @param string $text
104 *
105 * @return Comment
106 */
107 public function setText($text)
108 {
109 $this->text = $text;
110
111 return $this;
112 }
113
114 /**
115 * Get text.
116 *
117 * @return string
118 */
119 public function getText()
120 {
121 return $this->text;
122 }
123
124 /**
125 * @ORM\PrePersist
126 * @ORM\PreUpdate
127 */
128 public function timestamps()
129 {
130 if (is_null($this->createdAt)) {
131 $this->createdAt = new \DateTime();
132 }
133 $this->updatedAt = new \DateTime();
134 }
135
136 /**
137 * Get created.
138 *
139 * @return \DateTime
140 */
141 public function getCreatedAt()
142 {
143 return $this->createdAt;
144 }
145
146 /**
147 * Get updated.
148 *
149 * @return \DateTime
150 */
151 public function getUpdatedAt()
152 {
153 return $this->updatedAt;
154 }
155
156 /**
157 * Get quote.
158 *
159 * @return string
160 */
161 public function getQuote()
162 {
163 return $this->quote;
164 }
165
166 /**
167 * Set quote.
168 *
169 * @param string $quote
170 *
171 * @return Comment
172 */
173 public function setQuote($quote)
174 {
175 $this->quote = $quote;
176
177 return $this;
178 }
179
180 /**
181 * Get ranges.
182 *
183 * @return array
184 */
185 public function getRanges()
186 {
187 return $this->ranges;
188 }
189
190 /**
191 * Set ranges.
192 *
193 * @param array $ranges
194 *
195 * @return Comment
196 */
197 public function setRanges($ranges)
198 {
199 $this->ranges = $ranges;
200
201 return $this;
202 }
203
204 /**
205 * Set user.
206 *
207 * @param string $user
208 *
209 * @return Comment
210 */
211 public function setUser($user)
212 {
213 $this->user = $user;
214
215 return $this;
216 }
217
218 /**
219 * Get user.
220 *
221 * @return string
222 */
223 public function getUser()
224 {
225 return $this->user;
226 }
227
228 /**
229 * @VirtualProperty
230 * @SerializedName("user")
231 */
232 public function getUserName()
233 {
234 return $this->user->getName();
235 }
236
237 /**
238 * Set entry.
239 *
240 * @param Entry $entry
241 *
242 * @return Comment
243 */
244 public function setEntry($entry)
245 {
246 $this->entry = $entry;
247 $entry->setComment($this);
248
249 return $this;
250 }
251
252 /**
253 * Get entry.
254 *
255 * @return Entry
256 */
257 public function getEntry()
258 {
259 return $this->entry;
260 }
261
262 /**
263 * @VirtualProperty
264 * @SerializedName("annotator_schema_version")
265 */
266 public function getVersion()
267 {
268 return 'v1.0';
269 }
270}