From c675bd11c66e60a1976dfd66484448dcc9d80f0f Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 23 Jun 2019 22:13:06 +0200 Subject: Add IgnoreOriginRule-related entities, db migration, update config Add IgnoreOriginUserRule for user-defined rules and IgnoreOriginInstanceRule for system-wide rules. Add an interface for these two new entities. Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Entity/Config.php | 25 ++++++ .../CoreBundle/Entity/IgnoreOriginInstanceRule.php | 71 ++++++++++++++++ .../Entity/IgnoreOriginRuleInterface.php | 12 +++ .../CoreBundle/Entity/IgnoreOriginUserRule.php | 98 ++++++++++++++++++++++ src/Wallabag/CoreBundle/Entity/RuleInterface.php | 7 ++ src/Wallabag/CoreBundle/Entity/TaggingRule.php | 2 +- 6 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php create mode 100644 src/Wallabag/CoreBundle/Entity/IgnoreOriginRuleInterface.php create mode 100644 src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php create mode 100644 src/Wallabag/CoreBundle/Entity/RuleInterface.php (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index fe7942ee..1bed4513 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -119,6 +119,12 @@ class Config */ private $taggingRules; + /** + * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\IgnoreOriginUserRule", mappedBy="config", cascade={"remove"}) + * @ORM\OrderBy({"id" = "ASC"}) + */ + private $ignoreOriginRules; + /* * @param User $user */ @@ -126,6 +132,7 @@ class Config { $this->user = $user; $this->taggingRules = new ArrayCollection(); + $this->ignoreOriginRules = new ArrayCollection(); } /** @@ -387,4 +394,22 @@ class Config { return $this->taggingRules; } + + /** + * @return Config + */ + public function addIgnoreOriginRule(IgnoreOriginUserRule $rule) + { + $this->ignoreOriginRules[] = $rule; + + return $this; + } + + /** + * @return ArrayCollection + */ + public function getIgnoreOriginRules() + { + return $this->ignoreOriginRules; + } } diff --git a/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php b/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php new file mode 100644 index 00000000..34aed50c --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php @@ -0,0 +1,71 @@ +id; + } + + /** + * Set rule. + * + * @return IgnoreOriginRuleInterface + */ + public function setRule(string $rule) + { + $this->rule = $rule; + + return $this; + } + + /** + * Get rule. + * + * @return string + */ + public function getRule() + { + return $this->rule; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/IgnoreOriginRuleInterface.php b/src/Wallabag/CoreBundle/Entity/IgnoreOriginRuleInterface.php new file mode 100644 index 00000000..eb865a3a --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/IgnoreOriginRuleInterface.php @@ -0,0 +1,12 @@ +id; + } + + /** + * Set rule. + * + * @return IgnoreOriginRuleInterface + */ + public function setRule(string $rule) + { + $this->rule = $rule; + + return $this; + } + + /** + * Get rule. + * + * @return string + */ + public function getRule() + { + return $this->rule; + } + + /** + * Set config. + * + * @return IgnoreOriginUserRule + */ + public function setConfig(Config $config) + { + $this->config = $config; + + return $this; + } + + /** + * Get config. + * + * @return Config + */ + public function getConfig() + { + return $this->config; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/RuleInterface.php b/src/Wallabag/CoreBundle/Entity/RuleInterface.php new file mode 100644 index 00000000..8e9b5c45 --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/RuleInterface.php @@ -0,0 +1,7 @@ + Date: Sun, 11 Aug 2019 23:51:55 +0200 Subject: Add new Helper to process Ignore Origin rules and RulerZ operator This commits adds a new helper like RuleBasedTagger for processing ignore origin rules. It also adds a new custom RulerZ operator for the '~' pattern matching rule. Renames 'pattern' with '_all' in IgnoreOriginRule entity. Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php | 3 +-- src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php b/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php index 34aed50c..ce3b6e7d 100644 --- a/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php +++ b/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php @@ -11,7 +11,6 @@ use Symfony\Component\Validator\Constraints as Assert; * * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository") * @ORM\Table(name="`ignore_origin_instance_rule`") - * @ORM\Entity */ class IgnoreOriginInstanceRule implements IgnoreOriginRuleInterface, RuleInterface { @@ -30,7 +29,7 @@ class IgnoreOriginInstanceRule implements IgnoreOriginRuleInterface, RuleInterfa * @Assert\NotBlank() * @Assert\Length(max=255) * @RulerZAssert\ValidRule( - * allowed_variables={"host","pattern"}, + * allowed_variables={"host","_all"}, * allowed_operators={"=","~"} * ) * @ORM\Column(name="rule", type="string", nullable=false) diff --git a/src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php b/src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php index befd6090..0b6f318d 100644 --- a/src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php +++ b/src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php @@ -11,7 +11,6 @@ use Symfony\Component\Validator\Constraints as Assert; * * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\IgnoreOriginUserRuleRepository") * @ORM\Table(name="`ignore_origin_user_rule`") - * @ORM\Entity */ class IgnoreOriginUserRule implements IgnoreOriginRuleInterface, RuleInterface { @@ -30,7 +29,7 @@ class IgnoreOriginUserRule implements IgnoreOriginRuleInterface, RuleInterface * @Assert\NotBlank() * @Assert\Length(max=255) * @RulerZAssert\ValidRule( - * allowed_variables={"host","pattern"}, + * allowed_variables={"host","_all"}, * allowed_operators={"=","~"} * ) * @ORM\Column(name="rule", type="string", nullable=false) -- cgit v1.2.3