3 namespace Wallabag\AnnotationBundle\Entity
;
5 use Doctrine\ORM\Mapping
as ORM
;
6 use JMS\Serializer\Annotation\ExclusionPolicy
;
7 use JMS\Serializer\Annotation\Exclude
;
8 use JMS\Serializer\Annotation\VirtualProperty
;
9 use JMS\Serializer\Annotation\SerializedName
;
10 use JMS\Serializer\Annotation\Groups
;
11 use Symfony\Component\Validator\Constraints
as Assert
;
12 use Wallabag\UserBundle\Entity\User
;
13 use Wallabag\CoreBundle\Entity\Entry
;
18 * @ORM\Table(name="annotation")
19 * @ORM\Entity(repositoryClass="Wallabag\AnnotationBundle\Repository\AnnotationRepository")
20 * @ORM\HasLifecycleCallbacks()
21 * @ExclusionPolicy("none")
28 * @ORM\Column(name="id", type="integer")
30 * @ORM\GeneratedValue(strategy="AUTO")
37 * @ORM\Column(name="text", type="text")
39 * @Groups({"entries_for_user", "export_all"})
46 * @ORM\Column(name="created_at", type="datetime")
53 * @ORM\Column(name="updated_at", type="datetime")
62 * maxMessage = "validator.quote_length_too_high"
64 * @ORM\Column(name="quote", type="text")
66 * @Groups({"entries_for_user", "export_all"})
73 * @ORM\Column(name="ranges", type="array")
75 * @Groups({"entries_for_user", "export_all"})
82 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User")
89 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry", inversedBy="annotations")
90 * @ORM\JoinColumn(name="entry_id", referencedColumnName="id", onDelete="cascade")
97 public function __construct(User
$user)
107 public function getId()
115 * @param string $text
119 public function setText($text)
131 public function getText()
140 public function timestamps()
142 if (is_null($this->createdAt
)) {
143 $this->createdAt
= new \
DateTime();
145 $this->updatedAt
= new \
DateTime();
153 public function getCreatedAt()
155 return $this->createdAt
;
163 public function getUpdatedAt()
165 return $this->updatedAt
;
173 public function getQuote()
181 * @param string $quote
185 public function setQuote($quote)
187 $this->quote
= $quote;
197 public function getRanges()
199 return $this->ranges
;
205 * @param array $ranges
209 public function setRanges($ranges)
211 $this->ranges
= $ranges;
223 public function setUser($user)
235 public function getUser()
242 * @SerializedName("user")
244 public function getUserName()
246 return $this->user
->getName();
252 * @param Entry $entry
256 public function setEntry($entry)
258 $this->entry
= $entry;
259 $entry->setAnnotation($this);
269 public function getEntry()
276 * @SerializedName("annotator_schema_version")
278 public function getVersion()