diff options
author | Kevin Decherf <kevin@kdecherf.com> | 2020-04-26 15:39:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-26 15:39:57 +0200 |
commit | 0e8a0f77d0b643a884e6687bd9c463267852a970 (patch) | |
tree | 88c6761b4215637bba34b263015e87750c92a187 /src/Wallabag/CoreBundle/Entity | |
parent | 8a8a78a64c116caf81aaa4339906298bdc0e32e0 (diff) | |
parent | 71f7e58fbd84e1d15c7a405a3c5872adb937dc37 (diff) | |
download | wallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.tar.gz wallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.tar.zst wallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.zip |
Merge pull request #4026 from wallabag/3760-ignorelist-db
Move Ignore Origin rules to database
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity')
6 files changed, 212 insertions, 1 deletions
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 | |||
119 | */ | 119 | */ |
120 | private $taggingRules; | 120 | private $taggingRules; |
121 | 121 | ||
122 | /** | ||
123 | * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\IgnoreOriginUserRule", mappedBy="config", cascade={"remove"}) | ||
124 | * @ORM\OrderBy({"id" = "ASC"}) | ||
125 | */ | ||
126 | private $ignoreOriginRules; | ||
127 | |||
122 | /* | 128 | /* |
123 | * @param User $user | 129 | * @param User $user |
124 | */ | 130 | */ |
@@ -126,6 +132,7 @@ class Config | |||
126 | { | 132 | { |
127 | $this->user = $user; | 133 | $this->user = $user; |
128 | $this->taggingRules = new ArrayCollection(); | 134 | $this->taggingRules = new ArrayCollection(); |
135 | $this->ignoreOriginRules = new ArrayCollection(); | ||
129 | } | 136 | } |
130 | 137 | ||
131 | /** | 138 | /** |
@@ -387,4 +394,22 @@ class Config | |||
387 | { | 394 | { |
388 | return $this->taggingRules; | 395 | return $this->taggingRules; |
389 | } | 396 | } |
397 | |||
398 | /** | ||
399 | * @return Config | ||
400 | */ | ||
401 | public function addIgnoreOriginRule(IgnoreOriginUserRule $rule) | ||
402 | { | ||
403 | $this->ignoreOriginRules[] = $rule; | ||
404 | |||
405 | return $this; | ||
406 | } | ||
407 | |||
408 | /** | ||
409 | * @return ArrayCollection<IgnoreOriginUserRule> | ||
410 | */ | ||
411 | public function getIgnoreOriginRules() | ||
412 | { | ||
413 | return $this->ignoreOriginRules; | ||
414 | } | ||
390 | } | 415 | } |
diff --git a/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php b/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php new file mode 100644 index 00000000..ce3b6e7d --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php | |||
@@ -0,0 +1,70 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Entity; | ||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; | ||
6 | use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert; | ||
7 | use Symfony\Component\Validator\Constraints as Assert; | ||
8 | |||
9 | /** | ||
10 | * Ignore Origin rule. | ||
11 | * | ||
12 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository") | ||
13 | * @ORM\Table(name="`ignore_origin_instance_rule`") | ||
14 | */ | ||
15 | class IgnoreOriginInstanceRule implements IgnoreOriginRuleInterface, RuleInterface | ||
16 | { | ||
17 | /** | ||
18 | * @var int | ||
19 | * | ||
20 | * @ORM\Column(name="id", type="integer") | ||
21 | * @ORM\Id | ||
22 | * @ORM\GeneratedValue(strategy="AUTO") | ||
23 | */ | ||
24 | private $id; | ||
25 | |||
26 | /** | ||
27 | * @var string | ||
28 | * | ||
29 | * @Assert\NotBlank() | ||
30 | * @Assert\Length(max=255) | ||
31 | * @RulerZAssert\ValidRule( | ||
32 | * allowed_variables={"host","_all"}, | ||
33 | * allowed_operators={"=","~"} | ||
34 | * ) | ||
35 | * @ORM\Column(name="rule", type="string", nullable=false) | ||
36 | */ | ||
37 | private $rule; | ||
38 | |||
39 | /** | ||
40 | * Get id. | ||
41 | * | ||
42 | * @return int | ||
43 | */ | ||
44 | public function getId() | ||
45 | { | ||
46 | return $this->id; | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * Set rule. | ||
51 | * | ||
52 | * @return IgnoreOriginRuleInterface | ||
53 | */ | ||
54 | public function setRule(string $rule) | ||
55 | { | ||
56 | $this->rule = $rule; | ||
57 | |||
58 | return $this; | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Get rule. | ||
63 | * | ||
64 | * @return string | ||
65 | */ | ||
66 | public function getRule() | ||
67 | { | ||
68 | return $this->rule; | ||
69 | } | ||
70 | } | ||
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 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Entity; | ||
4 | |||
5 | interface IgnoreOriginRuleInterface | ||
6 | { | ||
7 | public function getId(); | ||
8 | |||
9 | public function setRule(string $rule); | ||
10 | |||
11 | public function getRule(); | ||
12 | } | ||
diff --git a/src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php b/src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php new file mode 100644 index 00000000..0b6f318d --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php | |||
@@ -0,0 +1,97 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Entity; | ||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; | ||
6 | use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert; | ||
7 | use Symfony\Component\Validator\Constraints as Assert; | ||
8 | |||
9 | /** | ||
10 | * Ignore Origin rule. | ||
11 | * | ||
12 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\IgnoreOriginUserRuleRepository") | ||
13 | * @ORM\Table(name="`ignore_origin_user_rule`") | ||
14 | */ | ||
15 | class IgnoreOriginUserRule implements IgnoreOriginRuleInterface, RuleInterface | ||
16 | { | ||
17 | /** | ||
18 | * @var int | ||
19 | * | ||
20 | * @ORM\Column(name="id", type="integer") | ||
21 | * @ORM\Id | ||
22 | * @ORM\GeneratedValue(strategy="AUTO") | ||
23 | */ | ||
24 | private $id; | ||
25 | |||
26 | /** | ||
27 | * @var string | ||
28 | * | ||
29 | * @Assert\NotBlank() | ||
30 | * @Assert\Length(max=255) | ||
31 | * @RulerZAssert\ValidRule( | ||
32 | * allowed_variables={"host","_all"}, | ||
33 | * allowed_operators={"=","~"} | ||
34 | * ) | ||
35 | * @ORM\Column(name="rule", type="string", nullable=false) | ||
36 | */ | ||
37 | private $rule; | ||
38 | |||
39 | /** | ||
40 | * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", inversedBy="ignoreOriginRules") | ||
41 | */ | ||
42 | private $config; | ||
43 | |||
44 | /** | ||
45 | * Get id. | ||
46 | * | ||
47 | * @return int | ||
48 | */ | ||
49 | public function getId() | ||
50 | { | ||
51 | return $this->id; | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * Set rule. | ||
56 | * | ||
57 | * @return IgnoreOriginRuleInterface | ||
58 | */ | ||
59 | public function setRule(string $rule) | ||
60 | { | ||
61 | $this->rule = $rule; | ||
62 | |||
63 | return $this; | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * Get rule. | ||
68 | * | ||
69 | * @return string | ||
70 | */ | ||
71 | public function getRule() | ||
72 | { | ||
73 | return $this->rule; | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * Set config. | ||
78 | * | ||
79 | * @return IgnoreOriginUserRule | ||
80 | */ | ||
81 | public function setConfig(Config $config) | ||
82 | { | ||
83 | $this->config = $config; | ||
84 | |||
85 | return $this; | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * Get config. | ||
90 | * | ||
91 | * @return Config | ||
92 | */ | ||
93 | public function getConfig() | ||
94 | { | ||
95 | return $this->config; | ||
96 | } | ||
97 | } | ||
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 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Entity; | ||
4 | |||
5 | interface RuleInterface | ||
6 | { | ||
7 | } | ||
diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php index f7166087..7bed7a69 100644 --- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php | |||
@@ -17,7 +17,7 @@ use Symfony\Component\Validator\Constraints as Assert; | |||
17 | * @ORM\Table(name="`tagging_rule`") | 17 | * @ORM\Table(name="`tagging_rule`") |
18 | * @ORM\Entity | 18 | * @ORM\Entity |
19 | */ | 19 | */ |
20 | class TaggingRule | 20 | class TaggingRule implements RuleInterface |
21 | { | 21 | { |
22 | /** | 22 | /** |
23 | * @var int | 23 | * @var int |