From ac9fec610a6485b39c856d9cb7d263ce8c5f1223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sun, 11 Oct 2015 17:14:50 +0200 Subject: Add TaggingRule entity --- src/Wallabag/CoreBundle/Entity/Config.php | 26 +++++ src/Wallabag/CoreBundle/Entity/TaggingRule.php | 128 +++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 src/Wallabag/CoreBundle/Entity/TaggingRule.php (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index b2a1915a..496fadb4 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -76,12 +76,18 @@ class Config */ private $user; + /** + * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\TaggingRule", mappedBy="config", cascade={"remove"}) + */ + private $taggingRules; + /* * @param User $user */ public function __construct(\Wallabag\UserBundle\Entity\User $user) { $this->user = $user; + $this->taggingRules = new ArrayCollection(); } /** @@ -237,4 +243,24 @@ class Config { return $this->rssLimit; } + + /** + * @param TaggingRule $rule + * + * @return Config + */ + public function addTaggingRule(TaggingRule $rule) + { + $this->taggingRules[] = $rule; + + return $this; + } + + /** + * @return ArrayCollection + */ + public function getTaggingRules() + { + return $this->taggingRules; + } } diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php new file mode 100644 index 00000000..6d03a34d --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php @@ -0,0 +1,128 @@ +id; + } + + /** + * Set rule. + * + * @param string $rule + * + * @return TaggingRule + */ + public function setRule($rule) + { + $this->rule = $rule; + + return $this; + } + + /** + * Get rule. + * + * @return string + */ + public function getRule() + { + return $this->rule; + } + + /** + * Set tags. + * + * @param array $tags + * + * @return TaggingRule + */ + public function setTags(array $tags) + { + $this->tags = $tags; + + return $this; + } + + /** + * Get tags. + * + * @return array + */ + public function getTags() + { + return $this->tags; + } + + /** + * Set config. + * + * @param Config $config + * + * @return TaggingRule + */ + public function setConfig(Config $config) + { + $this->config = $config; + + return $this; + } + + /** + * Get config. + * + * @return Config + */ + public function getConfig() + { + return $this->config; + } +} -- cgit v1.2.3 From 1d7b350b259ccc0110318a377ae3b3752ec6b9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sun, 11 Oct 2015 22:22:24 +0200 Subject: Add missing use statement --- src/Wallabag/CoreBundle/Entity/Config.php | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index 496fadb4..1204efa8 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -2,6 +2,7 @@ namespace Wallabag\CoreBundle\Entity; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; -- cgit v1.2.3 From 3447d1ee07bb64e57e69164127529f957dd47822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Wed, 14 Oct 2015 22:48:58 +0200 Subject: =?UTF-8?q?Add=20na=C3=AFve=20validation=20for=20tagging=20rules?= =?UTF-8?q?=20(only=20checks=20the=20syntax)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Wallabag/CoreBundle/Entity/TaggingRule.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php index 6d03a34d..20c15258 100644 --- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php @@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; +use KPhoen\RulerZBundle\Validator\Constraints as RulerZAssert; /** * Config. @@ -27,6 +28,7 @@ class TaggingRule * @var string * * @Assert\NotBlank() + * @RulerZAssert\ValidRule() * @ORM\Column(name="rule", type="string", nullable=false) */ private $rule; -- cgit v1.2.3 From 1dc4e5da2e281ee8acc69ff025c42369cf778387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 17 Oct 2015 16:57:41 +0200 Subject: Also validate used variables when creating tagging rules --- src/Wallabag/CoreBundle/Entity/TaggingRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php index 20c15258..97a29336 100644 --- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php @@ -28,7 +28,7 @@ class TaggingRule * @var string * * @Assert\NotBlank() - * @RulerZAssert\ValidRule() + * @RulerZAssert\ValidRule(allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"}) * @ORM\Column(name="rule", type="string", nullable=false) */ private $rule; -- cgit v1.2.3 From c23fc05df86c3cdb8eb40994b98d057f4a81b02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sun, 18 Oct 2015 14:32:58 +0200 Subject: Validate used operators when creating tagging rules --- src/Wallabag/CoreBundle/Entity/TaggingRule.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php index 97a29336..472ae582 100644 --- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php @@ -28,7 +28,10 @@ class TaggingRule * @var string * * @Assert\NotBlank() - * @RulerZAssert\ValidRule(allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"}) + * @RulerZAssert\ValidRule( + * allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"}, + * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or"} + * ) * @ORM\Column(name="rule", type="string", nullable=false) */ private $rule; -- cgit v1.2.3 From 625acf335298186b4ff983f9321900d1238e854b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 24 Oct 2015 15:11:06 +0200 Subject: Add a command to automatically tag all entries for a user --- src/Wallabag/CoreBundle/Entity/Entry.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 5aa582f8..608ed2f0 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -458,6 +458,10 @@ class Entry */ public function addTag(Tag $tag) { + if ($this->tags->contains($tag)) { + return; + } + $this->tags[] = $tag; $tag->addEntry($this); } -- cgit v1.2.3 From 7b1648961d2a9770e801f414d297efe3aace07e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 31 Oct 2015 16:29:38 +0100 Subject: Fix incorrect comment. --- src/Wallabag/CoreBundle/Entity/TaggingRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php index 472ae582..851af932 100644 --- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php @@ -7,7 +7,7 @@ use Symfony\Component\Validator\Constraints as Assert; use KPhoen\RulerZBundle\Validator\Constraints as RulerZAssert; /** - * Config. + * Tagging rule. * * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TaggingRuleRepository") * @ORM\Table -- cgit v1.2.3 From a6e27f74663637ecc4a4cf84028e6b5a3556a6ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Fri, 13 Nov 2015 14:37:58 +0100 Subject: Add matches operator --- src/Wallabag/CoreBundle/Entity/TaggingRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php index 851af932..4eab590f 100644 --- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php @@ -30,7 +30,7 @@ class TaggingRule * @Assert\NotBlank() * @RulerZAssert\ValidRule( * allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"}, - * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or"} + * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches"} * ) * @ORM\Column(name="rule", type="string", nullable=false) */ -- cgit v1.2.3 From 752b90d1f2e279d3662d5431b09c7587df2937ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sun, 29 Nov 2015 16:19:02 +0100 Subject: Fix tagging rules ordering --- src/Wallabag/CoreBundle/Entity/Config.php | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index 1204efa8..2ca4182e 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -79,6 +79,7 @@ class Config /** * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\TaggingRule", mappedBy="config", cascade={"remove"}) + * @ORM\OrderBy({"id" = "ASC"}) */ private $taggingRules; -- cgit v1.2.3