aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/AnnotationBundle/Entity/Annotation.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-02-26 18:17:37 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-02-26 18:17:37 +0100
commit162954763e6f68e0cf4002822007683bde62fc25 (patch)
treea85f850eddb30b3435d1bb5f45d16d9ab465bbf9 /src/Wallabag/AnnotationBundle/Entity/Annotation.php
parentd3f1a9dc1ac181033ec54f9149d2807199fa8f17 (diff)
parentb07c7dfe787313b75e0996265e13cccc78da41be (diff)
downloadwallabag-162954763e6f68e0cf4002822007683bde62fc25.tar.gz
wallabag-162954763e6f68e0cf4002822007683bde62fc25.tar.zst
wallabag-162954763e6f68e0cf4002822007683bde62fc25.zip
Merge pull request #1653 from wallabag/v2-annotator-comments
V2 annotator comments
Diffstat (limited to 'src/Wallabag/AnnotationBundle/Entity/Annotation.php')
-rw-r--r--src/Wallabag/AnnotationBundle/Entity/Annotation.php270
1 files changed, 270 insertions, 0 deletions
diff --git a/src/Wallabag/AnnotationBundle/Entity/Annotation.php b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
new file mode 100644
index 00000000..db9590b0
--- /dev/null
+++ b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
@@ -0,0 +1,270 @@
1<?php
2
3namespace Wallabag\AnnotationBundle\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 * Annotation.
15 *
16 * @ORM\Table(name="annotation")
17 * @ORM\Entity(repositoryClass="Wallabag\AnnotationBundle\Repository\AnnotationRepository")
18 * @ORM\HasLifecycleCallbacks()
19 * @ExclusionPolicy("none")
20 */
21class Annotation
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="annotations")
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 Annotation
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 Annotation
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 Annotation
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 Annotation
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 Annotation
243 */
244 public function setEntry($entry)
245 {
246 $this->entry = $entry;
247 $entry->setAnnotation($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}