]>
Commit | Line | Data |
---|---|---|
ac9fec61 KG |
1 | <?php |
2 | ||
3 | namespace Wallabag\CoreBundle\Entity; | |
4 | ||
5 | use Doctrine\ORM\Mapping as ORM; | |
34be2d5d JB |
6 | use JMS\Serializer\Annotation\Exclude; |
7 | use JMS\Serializer\Annotation\Groups; | |
8 | use JMS\Serializer\Annotation\XmlRoot; | |
0f159f8f | 9 | use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert; |
619cc453 | 10 | use Symfony\Component\Validator\Constraints as Assert; |
ac9fec61 KG |
11 | |
12 | /** | |
7b164896 | 13 | * Tagging rule. |
ac9fec61 | 14 | * |
34be2d5d | 15 | * @XmlRoot("tagging_rule") |
ac9fec61 | 16 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TaggingRuleRepository") |
c5d0db8b | 17 | * @ORM\Table(name="`tagging_rule`") |
ac9fec61 KG |
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() | |
5aa0294c | 35 | * @Assert\Length(max=255) |
c23fc05d KG |
36 | * @RulerZAssert\ValidRule( |
37 | * allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"}, | |
fdd725f5 | 38 | * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches", "notmatches"} |
c23fc05d | 39 | * ) |
ac9fec61 | 40 | * @ORM\Column(name="rule", type="string", nullable=false) |
34be2d5d JB |
41 | * |
42 | * @Groups({"export_tagging_rule"}) | |
ac9fec61 KG |
43 | */ |
44 | private $rule; | |
45 | ||
46 | /** | |
47 | * @var array | |
48 | * | |
49 | * @Assert\NotBlank() | |
50 | * @ORM\Column(name="tags", type="simple_array", nullable=false) | |
34be2d5d JB |
51 | * |
52 | * @Groups({"export_tagging_rule"}) | |
ac9fec61 KG |
53 | */ |
54 | private $tags = []; | |
55 | ||
56 | /** | |
34be2d5d JB |
57 | * @Exclude |
58 | * | |
ac9fec61 KG |
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 | * | |
fdd725f5 | 100 | * @param array <string> $tags |
ac9fec61 KG |
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 | * | |
ac9fec61 KG |
124 | * @return TaggingRule |
125 | */ | |
126 | public function setConfig(Config $config) | |
127 | { | |
128 | $this->config = $config; | |
129 | ||
130 | return $this; | |
131 | } | |
132 | ||
133 | /** | |
134 | * Get config. | |
135 | * | |
136 | * @return Config | |
137 | */ | |
138 | public function getConfig() | |
139 | { | |
140 | return $this->config; | |
141 | } | |
142 | } |