]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Entity/TaggingRule.php
Add ability to import/export tagging rules
[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 JMS\Serializer\Annotation\Exclude;
7 use JMS\Serializer\Annotation\Groups;
8 use JMS\Serializer\Annotation\XmlRoot;
9 use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert;
10 use Symfony\Component\Validator\Constraints as Assert;
11
12 /**
13 * Tagging rule.
14 *
15 * @XmlRoot("tagging_rule")
16 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TaggingRuleRepository")
17 * @ORM\Table(name="`tagging_rule`")
18 * @ORM\Entity
19 */
20 class TaggingRule
21 {
22 /**
23 * @var int
24 *
25 * @ORM\Column(name="id", type="integer")
26 * @ORM\Id
27 * @ORM\GeneratedValue(strategy="AUTO")
28 */
29 private $id;
30
31 /**
32 * @var string
33 *
34 * @Assert\NotBlank()
35 * @Assert\Length(max=255)
36 * @RulerZAssert\ValidRule(
37 * allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"},
38 * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches", "notmatches"}
39 * )
40 * @ORM\Column(name="rule", type="string", nullable=false)
41 *
42 * @Groups({"export_tagging_rule"})
43 */
44 private $rule;
45
46 /**
47 * @var array
48 *
49 * @Assert\NotBlank()
50 * @ORM\Column(name="tags", type="simple_array", nullable=false)
51 *
52 * @Groups({"export_tagging_rule"})
53 */
54 private $tags = [];
55
56 /**
57 * @Exclude
58 *
59 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", inversedBy="taggingRules")
60 */
61 private $config;
62
63 /**
64 * Get id.
65 *
66 * @return int
67 */
68 public function getId()
69 {
70 return $this->id;
71 }
72
73 /**
74 * Set rule.
75 *
76 * @param string $rule
77 *
78 * @return TaggingRule
79 */
80 public function setRule($rule)
81 {
82 $this->rule = $rule;
83
84 return $this;
85 }
86
87 /**
88 * Get rule.
89 *
90 * @return string
91 */
92 public function getRule()
93 {
94 return $this->rule;
95 }
96
97 /**
98 * Set tags.
99 *
100 * @param array <string> $tags
101 *
102 * @return TaggingRule
103 */
104 public function setTags(array $tags)
105 {
106 $this->tags = $tags;
107
108 return $this;
109 }
110
111 /**
112 * Get tags.
113 *
114 * @return array<string>
115 */
116 public function getTags()
117 {
118 return $this->tags;
119 }
120
121 /**
122 * Set config.
123 *
124 * @param Config $config
125 *
126 * @return TaggingRule
127 */
128 public function setConfig(Config $config)
129 {
130 $this->config = $config;
131
132 return $this;
133 }
134
135 /**
136 * Get config.
137 *
138 * @return Config
139 */
140 public function getConfig()
141 {
142 return $this->config;
143 }
144 }