diff options
author | Kévin Gomez <contact@kevingomez.fr> | 2015-10-11 17:14:50 +0200 |
---|---|---|
committer | Kévin Gomez <contact@kevingomez.fr> | 2015-11-11 16:23:49 +0100 |
commit | ac9fec610a6485b39c856d9cb7d263ce8c5f1223 (patch) | |
tree | ef822c68bd263c6a1b99da8bc5edcfe1668c1ea3 /src/Wallabag/CoreBundle/Entity | |
parent | c3510620ad0718d2ab1f856e3a838360a5ade314 (diff) | |
download | wallabag-ac9fec610a6485b39c856d9cb7d263ce8c5f1223.tar.gz wallabag-ac9fec610a6485b39c856d9cb7d263ce8c5f1223.tar.zst wallabag-ac9fec610a6485b39c856d9cb7d263ce8c5f1223.zip |
Add TaggingRule entity
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Config.php | 26 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/TaggingRule.php | 128 |
2 files changed, 154 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index b2a1915a..496fadb4 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php | |||
@@ -76,12 +76,18 @@ class Config | |||
76 | */ | 76 | */ |
77 | private $user; | 77 | private $user; |
78 | 78 | ||
79 | /** | ||
80 | * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\TaggingRule", mappedBy="config", cascade={"remove"}) | ||
81 | */ | ||
82 | private $taggingRules; | ||
83 | |||
79 | /* | 84 | /* |
80 | * @param User $user | 85 | * @param User $user |
81 | */ | 86 | */ |
82 | public function __construct(\Wallabag\UserBundle\Entity\User $user) | 87 | public function __construct(\Wallabag\UserBundle\Entity\User $user) |
83 | { | 88 | { |
84 | $this->user = $user; | 89 | $this->user = $user; |
90 | $this->taggingRules = new ArrayCollection(); | ||
85 | } | 91 | } |
86 | 92 | ||
87 | /** | 93 | /** |
@@ -237,4 +243,24 @@ class Config | |||
237 | { | 243 | { |
238 | return $this->rssLimit; | 244 | return $this->rssLimit; |
239 | } | 245 | } |
246 | |||
247 | /** | ||
248 | * @param TaggingRule $rule | ||
249 | * | ||
250 | * @return Config | ||
251 | */ | ||
252 | public function addTaggingRule(TaggingRule $rule) | ||
253 | { | ||
254 | $this->taggingRules[] = $rule; | ||
255 | |||
256 | return $this; | ||
257 | } | ||
258 | |||
259 | /** | ||
260 | * @return ArrayCollection<TaggingRule> | ||
261 | */ | ||
262 | public function getTaggingRules() | ||
263 | { | ||
264 | return $this->taggingRules; | ||
265 | } | ||
240 | } | 266 | } |
diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php new file mode 100644 index 00000000..6d03a34d --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php | |||
@@ -0,0 +1,128 @@ | |||
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 | |||
8 | /** | ||
9 | * Config. | ||
10 | * | ||
11 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TaggingRuleRepository") | ||
12 | * @ORM\Table | ||
13 | * @ORM\Entity | ||
14 | */ | ||
15 | class TaggingRule | ||
16 | { | ||
17 | /** | ||
18 | * @var int | ||
19 | * | ||
20 | * @ORM\Column(name="id", type="integer") | ||
21 | * @ORM\Id | ||
22 | * @ORM\GeneratedValue(strategy="AUTO") | ||
23 | */ | ||
24 | private $id; | ||
25 | |||
26 | /** | ||
27 | * @var string | ||
28 | * | ||
29 | * @Assert\NotBlank() | ||
30 | * @ORM\Column(name="rule", type="string", nullable=false) | ||
31 | */ | ||
32 | private $rule; | ||
33 | |||
34 | /** | ||
35 | * @var array | ||
36 | * | ||
37 | * @Assert\NotBlank() | ||
38 | * @ORM\Column(name="tags", type="simple_array", nullable=false) | ||
39 | */ | ||
40 | private $tags = []; | ||
41 | |||
42 | /** | ||
43 | * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", inversedBy="taggingRules") | ||
44 | */ | ||
45 | private $config; | ||
46 | |||
47 | /** | ||
48 | * Get id. | ||
49 | * | ||
50 | * @return int | ||
51 | */ | ||
52 | public function getId() | ||
53 | { | ||
54 | return $this->id; | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * Set rule. | ||
59 | * | ||
60 | * @param string $rule | ||
61 | * | ||
62 | * @return TaggingRule | ||
63 | */ | ||
64 | public function setRule($rule) | ||
65 | { | ||
66 | $this->rule = $rule; | ||
67 | |||
68 | return $this; | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * Get rule. | ||
73 | * | ||
74 | * @return string | ||
75 | */ | ||
76 | public function getRule() | ||
77 | { | ||
78 | return $this->rule; | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * Set tags. | ||
83 | * | ||
84 | * @param array<string> $tags | ||
85 | * | ||
86 | * @return TaggingRule | ||
87 | */ | ||
88 | public function setTags(array $tags) | ||
89 | { | ||
90 | $this->tags = $tags; | ||
91 | |||
92 | return $this; | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * Get tags. | ||
97 | * | ||
98 | * @return array<string> | ||
99 | */ | ||
100 | public function getTags() | ||
101 | { | ||
102 | return $this->tags; | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * Set config. | ||
107 | * | ||
108 | * @param Config $config | ||
109 | * | ||
110 | * @return TaggingRule | ||
111 | */ | ||
112 | public function setConfig(Config $config) | ||
113 | { | ||
114 | $this->config = $config; | ||
115 | |||
116 | return $this; | ||
117 | } | ||
118 | |||
119 | /** | ||
120 | * Get config. | ||
121 | * | ||
122 | * @return Config | ||
123 | */ | ||
124 | public function getConfig() | ||
125 | { | ||
126 | return $this->config; | ||
127 | } | ||
128 | } | ||