aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2019-06-23 22:13:06 +0200
committerKevin Decherf <kevin@kdecherf.com>2020-04-25 15:59:23 +0200
commitc675bd11c66e60a1976dfd66484448dcc9d80f0f (patch)
tree609a1b8d355365ccf83b70bf5df6b140bb86e196 /src
parent8a8a78a64c116caf81aaa4339906298bdc0e32e0 (diff)
downloadwallabag-c675bd11c66e60a1976dfd66484448dcc9d80f0f.tar.gz
wallabag-c675bd11c66e60a1976dfd66484448dcc9d80f0f.tar.zst
wallabag-c675bd11c66e60a1976dfd66484448dcc9d80f0f.zip
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 <kevin@kdecherf.com>
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Config.php25
-rw-r--r--src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php71
-rw-r--r--src/Wallabag/CoreBundle/Entity/IgnoreOriginRuleInterface.php12
-rw-r--r--src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php98
-rw-r--r--src/Wallabag/CoreBundle/Entity/RuleInterface.php7
-rw-r--r--src/Wallabag/CoreBundle/Entity/TaggingRule.php2
-rw-r--r--src/Wallabag/CoreBundle/Repository/IgnoreOriginInstanceRuleRepository.php9
-rw-r--r--src/Wallabag/CoreBundle/Repository/IgnoreOriginUserRuleRepository.php9
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml6
9 files changed, 238 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..34aed50c
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php
@@ -0,0 +1,71 @@
1<?php
2
3namespace Wallabag\CoreBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert;
7use 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 * @ORM\Entity
15 */
16class IgnoreOriginInstanceRule implements IgnoreOriginRuleInterface, RuleInterface
17{
18 /**
19 * @var int
20 *
21 * @ORM\Column(name="id", type="integer")
22 * @ORM\Id
23 * @ORM\GeneratedValue(strategy="AUTO")
24 */
25 private $id;
26
27 /**
28 * @var string
29 *
30 * @Assert\NotBlank()
31 * @Assert\Length(max=255)
32 * @RulerZAssert\ValidRule(
33 * allowed_variables={"host","pattern"},
34 * allowed_operators={"=","~"}
35 * )
36 * @ORM\Column(name="rule", type="string", nullable=false)
37 */
38 private $rule;
39
40 /**
41 * Get id.
42 *
43 * @return int
44 */
45 public function getId()
46 {
47 return $this->id;
48 }
49
50 /**
51 * Set rule.
52 *
53 * @return IgnoreOriginRuleInterface
54 */
55 public function setRule(string $rule)
56 {
57 $this->rule = $rule;
58
59 return $this;
60 }
61
62 /**
63 * Get rule.
64 *
65 * @return string
66 */
67 public function getRule()
68 {
69 return $this->rule;
70 }
71}
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
3namespace Wallabag\CoreBundle\Entity;
4
5interface 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..befd6090
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php
@@ -0,0 +1,98 @@
1<?php
2
3namespace Wallabag\CoreBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert;
7use 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 * @ORM\Entity
15 */
16class IgnoreOriginUserRule implements IgnoreOriginRuleInterface, RuleInterface
17{
18 /**
19 * @var int
20 *
21 * @ORM\Column(name="id", type="integer")
22 * @ORM\Id
23 * @ORM\GeneratedValue(strategy="AUTO")
24 */
25 private $id;
26
27 /**
28 * @var string
29 *
30 * @Assert\NotBlank()
31 * @Assert\Length(max=255)
32 * @RulerZAssert\ValidRule(
33 * allowed_variables={"host","pattern"},
34 * allowed_operators={"=","~"}
35 * )
36 * @ORM\Column(name="rule", type="string", nullable=false)
37 */
38 private $rule;
39
40 /**
41 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", inversedBy="ignoreOriginRules")
42 */
43 private $config;
44
45 /**
46 * Get id.
47 *
48 * @return int
49 */
50 public function getId()
51 {
52 return $this->id;
53 }
54
55 /**
56 * Set rule.
57 *
58 * @return IgnoreOriginRuleInterface
59 */
60 public function setRule(string $rule)
61 {
62 $this->rule = $rule;
63
64 return $this;
65 }
66
67 /**
68 * Get rule.
69 *
70 * @return string
71 */
72 public function getRule()
73 {
74 return $this->rule;
75 }
76
77 /**
78 * Set config.
79 *
80 * @return IgnoreOriginUserRule
81 */
82 public function setConfig(Config $config)
83 {
84 $this->config = $config;
85
86 return $this;
87 }
88
89 /**
90 * Get config.
91 *
92 * @return Config
93 */
94 public function getConfig()
95 {
96 return $this->config;
97 }
98}
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
3namespace Wallabag\CoreBundle\Entity;
4
5interface 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 */
20class TaggingRule 20class TaggingRule implements RuleInterface
21{ 21{
22 /** 22 /**
23 * @var int 23 * @var int
diff --git a/src/Wallabag/CoreBundle/Repository/IgnoreOriginInstanceRuleRepository.php b/src/Wallabag/CoreBundle/Repository/IgnoreOriginInstanceRuleRepository.php
new file mode 100644
index 00000000..708a0ede
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Repository/IgnoreOriginInstanceRuleRepository.php
@@ -0,0 +1,9 @@
1<?php
2
3namespace Wallabag\CoreBundle\Repository;
4
5use Doctrine\ORM\EntityRepository;
6
7class IgnoreOriginInstanceRuleRepository extends EntityRepository
8{
9}
diff --git a/src/Wallabag/CoreBundle/Repository/IgnoreOriginUserRuleRepository.php b/src/Wallabag/CoreBundle/Repository/IgnoreOriginUserRuleRepository.php
new file mode 100644
index 00000000..8aa4c265
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Repository/IgnoreOriginUserRuleRepository.php
@@ -0,0 +1,9 @@
1<?php
2
3namespace Wallabag\CoreBundle\Repository;
4
5use Doctrine\ORM\EntityRepository;
6
7class IgnoreOriginUserRuleRepository extends EntityRepository
8{
9}
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index 3f3d4de7..4ece046a 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -131,6 +131,12 @@ services:
131 calls: 131 calls:
132 - [ setCrypto, [ "@wallabag_core.helper.crypto_proxy" ] ] 132 - [ setCrypto, [ "@wallabag_core.helper.crypto_proxy" ] ]
133 133
134 wallabag_core.ignore_origin_instance_rule_repository:
135 class: Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository
136 factory: [ "@doctrine.orm.default_entity_manager", getRepository ]
137 arguments:
138 - WallabagCoreBundle:IgnoreOriginInstanceRule
139
134 wallabag_core.helper.entries_export: 140 wallabag_core.helper.entries_export:
135 class: Wallabag\CoreBundle\Helper\EntriesExport 141 class: Wallabag\CoreBundle\Helper\EntriesExport
136 arguments: 142 arguments: