]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Entity/TaggingRule.php
Add naïve validation for tagging rules (only checks the syntax)
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / TaggingRule.php
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 * Config.
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 * @ORM\Column(name="rule", type="string", nullable=false)
33 */
34 private $rule;
35
36 /**
37 * @var array
38 *
39 * @Assert\NotBlank()
40 * @ORM\Column(name="tags", type="simple_array", nullable=false)
41 */
42 private $tags = [];
43
44 /**
45 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", inversedBy="taggingRules")
46 */
47 private $config;
48
49 /**
50 * Get id.
51 *
52 * @return int
53 */
54 public function getId()
55 {
56 return $this->id;
57 }
58
59 /**
60 * Set rule.
61 *
62 * @param string $rule
63 *
64 * @return TaggingRule
65 */
66 public function setRule($rule)
67 {
68 $this->rule = $rule;
69
70 return $this;
71 }
72
73 /**
74 * Get rule.
75 *
76 * @return string
77 */
78 public function getRule()
79 {
80 return $this->rule;
81 }
82
83 /**
84 * Set tags.
85 *
86 * @param array<string> $tags
87 *
88 * @return TaggingRule
89 */
90 public function setTags(array $tags)
91 {
92 $this->tags = $tags;
93
94 return $this;
95 }
96
97 /**
98 * Get tags.
99 *
100 * @return array<string>
101 */
102 public function getTags()
103 {
104 return $this->tags;
105 }
106
107 /**
108 * Set config.
109 *
110 * @param Config $config
111 *
112 * @return TaggingRule
113 */
114 public function setConfig(Config $config)
115 {
116 $this->config = $config;
117
118 return $this;
119 }
120
121 /**
122 * Get config.
123 *
124 * @return Config
125 */
126 public function getConfig()
127 {
128 return $this->config;
129 }
130 }