X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FAnnotationBundle%2FEntity%2FAnnotation.php;h=a180d504786c866686a70e34b8510d133e9e3b11;hb=927c9e796ff6fad2bf82a965234f52932cdee657;hp=90ee7c2d7e2200b484ae3c0d0550c15279390b38;hpb=cc8c2d315f6868201ff32cc4895844c800624a87;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/AnnotationBundle/Entity/Annotation.php b/src/Wallabag/AnnotationBundle/Entity/Annotation.php index 90ee7c2d..a180d504 100644 --- a/src/Wallabag/AnnotationBundle/Entity/Annotation.php +++ b/src/Wallabag/AnnotationBundle/Entity/Annotation.php @@ -3,12 +3,15 @@ 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. @@ -20,6 +23,8 @@ use Wallabag\CoreBundle\Entity\Entry; */ class Annotation { + use EntityTimestampsTrait; + /** * @var int * @@ -33,6 +38,8 @@ class Annotation * @var string * * @ORM\Column(name="text", type="text") + * + * @Groups({"entries_for_user", "export_all"}) */ private $text; @@ -53,7 +60,13 @@ class Annotation /** * @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; @@ -61,6 +74,8 @@ class Annotation * @var array * * @ORM\Column(name="ranges", type="array") + * + * @Groups({"entries_for_user", "export_all"}) */ private $ranges; @@ -75,7 +90,7 @@ class Annotation * @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; @@ -121,18 +136,6 @@ class Annotation 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. *