diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/TaggingRule.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/TaggingRule.php | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php new file mode 100644 index 00000000..4eab590f --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php | |||
@@ -0,0 +1,133 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Entity; | ||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; | ||
6 | use Symfony\Component\Validator\Constraints as Assert; | ||
7 | use KPhoen\RulerZBundle\Validator\Constraints as RulerZAssert; | ||
8 | |||
9 | /** | ||
10 | * Tagging rule. | ||
11 | * | ||
12 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TaggingRuleRepository") | ||
13 | * @ORM\Table | ||
14 | * @ORM\Entity | ||
15 | */ | ||
16 | class TaggingRule | ||
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 | * @RulerZAssert\ValidRule( | ||
32 | * allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"}, | ||
33 | * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches"} | ||
34 | * ) | ||
35 | * @ORM\Column(name="rule", type="string", nullable=false) | ||
36 | */ | ||
37 | private $rule; | ||
38 | |||
39 | /** | ||
40 | * @var array | ||
41 | * | ||
42 | * @Assert\NotBlank() | ||
43 | * @ORM\Column(name="tags", type="simple_array", nullable=false) | ||
44 | */ | ||
45 | private $tags = []; | ||
46 | |||
47 | /** | ||
48 | * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", inversedBy="taggingRules") | ||
49 | */ | ||
50 | private $config; | ||
51 | |||
52 | /** | ||
53 | * Get id. | ||
54 | * | ||
55 | * @return int | ||
56 | */ | ||
57 | public function getId() | ||
58 | { | ||
59 | return $this->id; | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Set rule. | ||
64 | * | ||
65 | * @param string $rule | ||
66 | * | ||
67 | * @return TaggingRule | ||
68 | */ | ||
69 | public function setRule($rule) | ||
70 | { | ||
71 | $this->rule = $rule; | ||
72 | |||
73 | return $this; | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * Get rule. | ||
78 | * | ||
79 | * @return string | ||
80 | */ | ||
81 | public function getRule() | ||
82 | { | ||
83 | return $this->rule; | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * Set tags. | ||
88 | * | ||
89 | * @param array<string> $tags | ||
90 | * | ||
91 | * @return TaggingRule | ||
92 | */ | ||
93 | public function setTags(array $tags) | ||
94 | { | ||
95 | $this->tags = $tags; | ||
96 | |||
97 | return $this; | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * Get tags. | ||
102 | * | ||
103 | * @return array<string> | ||
104 | */ | ||
105 | public function getTags() | ||
106 | { | ||
107 | return $this->tags; | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * Set config. | ||
112 | * | ||
113 | * @param Config $config | ||
114 | * | ||
115 | * @return TaggingRule | ||
116 | */ | ||
117 | public function setConfig(Config $config) | ||
118 | { | ||
119 | $this->config = $config; | ||
120 | |||
121 | return $this; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * Get config. | ||
126 | * | ||
127 | * @return Config | ||
128 | */ | ||
129 | public function getConfig() | ||
130 | { | ||
131 | return $this->config; | ||
132 | } | ||
133 | } | ||