namespace Wallabag\AnnotationBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
-use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Exclude;
-use JMS\Serializer\Annotation\VirtualProperty;
+use JMS\Serializer\Annotation\ExclusionPolicy;
+use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\SerializedName;
-use Wallabag\UserBundle\Entity\User;
+use JMS\Serializer\Annotation\VirtualProperty;
+use Symfony\Component\Validator\Constraints as Assert;
use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
+use Wallabag\UserBundle\Entity\User;
/**
* Annotation.
*/
class Annotation
{
+ use EntityTimestampsTrait;
+
/**
* @var int
*
* @var string
*
* @ORM\Column(name="text", type="text")
+ *
+ * @Groups({"entries_for_user", "export_all"})
*/
private $text;
/**
* @var string
*
- * @ORM\Column(name="quote", type="string")
+ * @Assert\Length(
+ * max = 10000,
+ * maxMessage = "validator.quote_length_too_high"
+ * )
+ * @ORM\Column(name="quote", type="text")
+ *
+ * @Groups({"entries_for_user", "export_all"})
*/
private $quote;
* @var array
*
* @ORM\Column(name="ranges", type="array")
+ *
+ * @Groups({"entries_for_user", "export_all"})
*/
private $ranges;
* @Exclude
*
* @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry", inversedBy="annotations")
- * @ORM\JoinColumn(name="entry_id", referencedColumnName="id")
+ * @ORM\JoinColumn(name="entry_id", referencedColumnName="id", onDelete="cascade")
*/
private $entry;
return $this->text;
}
- /**
- * @ORM\PrePersist
- * @ORM\PreUpdate
- */
- public function timestamps()
- {
- if (is_null($this->createdAt)) {
- $this->createdAt = new \DateTime();
- }
- $this->updatedAt = new \DateTime();
- }
-
/**
* Get created.
*