From 2c3e148b0029a094431622feac79fafcd0d43fc8 Mon Sep 17 00:00:00 2001 From: adev Date: Sun, 7 May 2017 17:21:30 +0200 Subject: Displays an error with an annotation with a too long quote Fix #2762 --- src/Wallabag/AnnotationBundle/Entity/Annotation.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/AnnotationBundle/Entity/Annotation.php') diff --git a/src/Wallabag/AnnotationBundle/Entity/Annotation.php b/src/Wallabag/AnnotationBundle/Entity/Annotation.php index 0838f5aa..c8e41649 100644 --- a/src/Wallabag/AnnotationBundle/Entity/Annotation.php +++ b/src/Wallabag/AnnotationBundle/Entity/Annotation.php @@ -8,6 +8,7 @@ use JMS\Serializer\Annotation\Exclude; use JMS\Serializer\Annotation\VirtualProperty; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Groups; +use Symfony\Component\Validator\Constraints as Assert; use Wallabag\UserBundle\Entity\User; use Wallabag\CoreBundle\Entity\Entry; @@ -56,7 +57,11 @@ 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"}) */ -- cgit v1.2.3 From f808b01692a835673f328d7221ba8c212caa9b61 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 1 Jul 2017 09:52:38 +0200 Subject: Add a real configuration for CS-Fixer --- src/Wallabag/AnnotationBundle/Entity/Annotation.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Wallabag/AnnotationBundle/Entity/Annotation.php') diff --git a/src/Wallabag/AnnotationBundle/Entity/Annotation.php b/src/Wallabag/AnnotationBundle/Entity/Annotation.php index c8e41649..04d83001 100644 --- a/src/Wallabag/AnnotationBundle/Entity/Annotation.php +++ b/src/Wallabag/AnnotationBundle/Entity/Annotation.php @@ -3,14 +3,14 @@ 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\SerializedName; +use JMS\Serializer\Annotation\ExclusionPolicy; use JMS\Serializer\Annotation\Groups; +use JMS\Serializer\Annotation\SerializedName; +use JMS\Serializer\Annotation\VirtualProperty; use Symfony\Component\Validator\Constraints as Assert; -use Wallabag\UserBundle\Entity\User; use Wallabag\CoreBundle\Entity\Entry; +use Wallabag\UserBundle\Entity\User; /** * Annotation. @@ -139,7 +139,7 @@ class Annotation */ public function timestamps() { - if (is_null($this->createdAt)) { + if (null === $this->createdAt) { $this->createdAt = new \DateTime(); } $this->updatedAt = new \DateTime(); -- cgit v1.2.3 From 927c9e796ff6fad2bf82a965234f52932cdee657 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 6 Jul 2017 09:00:37 +0200 Subject: Add EntityTimestampsTrait to handle dates Refactorize timestamps() method to avoid re-writing it on each entity --- src/Wallabag/AnnotationBundle/Entity/Annotation.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/Wallabag/AnnotationBundle/Entity/Annotation.php') diff --git a/src/Wallabag/AnnotationBundle/Entity/Annotation.php b/src/Wallabag/AnnotationBundle/Entity/Annotation.php index 04d83001..a180d504 100644 --- a/src/Wallabag/AnnotationBundle/Entity/Annotation.php +++ b/src/Wallabag/AnnotationBundle/Entity/Annotation.php @@ -10,6 +10,7 @@ use JMS\Serializer\Annotation\SerializedName; 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; /** @@ -22,6 +23,8 @@ use Wallabag\UserBundle\Entity\User; */ class Annotation { + use EntityTimestampsTrait; + /** * @var int * @@ -133,18 +136,6 @@ class Annotation return $this->text; } - /** - * @ORM\PrePersist - * @ORM\PreUpdate - */ - public function timestamps() - { - if (null === $this->createdAt) { - $this->createdAt = new \DateTime(); - } - $this->updatedAt = new \DateTime(); - } - /** * Get created. * -- cgit v1.2.3