]>
Commit | Line | Data |
---|---|---|
9d50517c NL |
1 | <?php |
2 | ||
ad4d1caa | 3 | namespace Wallabag\CoreBundle\Entity; |
9d50517c | 4 | |
1d7b350b | 5 | use Doctrine\Common\Collections\ArrayCollection; |
9d50517c | 6 | use Doctrine\ORM\Mapping as ORM; |
55f58c9c | 7 | use Symfony\Component\Validator\Constraints as Assert; |
8eedc8cf | 8 | use Wallabag\UserBundle\Entity\User; |
9d50517c NL |
9 | |
10 | /** | |
4346a860 | 11 | * Config. |
9d50517c | 12 | * |
4d85d7e9 | 13 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\ConfigRepository") |
0810c75e JB |
14 | * @ORM\Table( |
15 | * name="`config`", | |
16 | * indexes={ | |
17 | * @ORM\Index(name="config_feed_token", columns={"feed_token"}, options={"lengths"={255}}), | |
18 | * } | |
19 | * ) | |
9d50517c NL |
20 | */ |
21 | class Config | |
22 | { | |
f052f1fd NL |
23 | const REDIRECT_TO_HOMEPAGE = 0; |
24 | const REDIRECT_TO_CURRENT_PAGE = 1; | |
25 | ||
9d50517c | 26 | /** |
4346a860 | 27 | * @var int |
9d50517c | 28 | * |
55f58c9c | 29 | * @ORM\Column(name="id", type="integer") |
9d50517c | 30 | * @ORM\Id |
55f58c9c | 31 | * @ORM\GeneratedValue(strategy="AUTO") |
9d50517c NL |
32 | */ |
33 | private $id; | |
34 | ||
35 | /** | |
36 | * @var string | |
37 | * | |
55f58c9c | 38 | * @Assert\NotBlank() |
4d85d7e9 | 39 | * @ORM\Column(name="theme", type="string", nullable=false) |
9d50517c | 40 | */ |
4d85d7e9 | 41 | private $theme; |
9d50517c NL |
42 | |
43 | /** | |
4346a860 | 44 | * @var int |
9d50517c | 45 | * |
4d85d7e9 | 46 | * @Assert\NotBlank() |
371ac69a J |
47 | * @Assert\Range( |
48 | * min = 1, | |
49 | * max = 100000, | |
0d42217e | 50 | * maxMessage = "validator.item_per_page_too_high" |
371ac69a | 51 | * ) |
4d85d7e9 J |
52 | * @ORM\Column(name="items_per_page", type="integer", nullable=false) |
53 | */ | |
0c83fd59 | 54 | private $itemsPerPage; |
4d85d7e9 J |
55 | |
56 | /** | |
57 | * @var string | |
58 | * | |
59 | * @Assert\NotBlank() | |
60 | * @ORM\Column(name="language", type="string", nullable=false) | |
9d50517c | 61 | */ |
4d85d7e9 J |
62 | private $language; |
63 | ||
0c83fd59 J |
64 | /** |
65 | * @var string | |
66 | * | |
f277bc04 | 67 | * @ORM\Column(name="feed_token", type="string", nullable=true) |
0c83fd59 | 68 | */ |
531c8d0a | 69 | private $feedToken; |
0c83fd59 J |
70 | |
71 | /** | |
4346a860 | 72 | * @var int |
0c83fd59 | 73 | * |
f277bc04 | 74 | * @ORM\Column(name="feed_limit", type="integer", nullable=true) |
371ac69a J |
75 | * @Assert\Range( |
76 | * min = 1, | |
77 | * max = 100000, | |
531c8d0a | 78 | * maxMessage = "validator.feed_limit_too_high" |
371ac69a | 79 | * ) |
0c83fd59 | 80 | */ |
531c8d0a | 81 | private $feedLimit; |
0c83fd59 | 82 | |
bca54859 NL |
83 | /** |
84 | * @var float | |
85 | * | |
86 | * @ORM\Column(name="reading_speed", type="float", nullable=true) | |
87 | */ | |
88 | private $readingSpeed; | |
89 | ||
ebe0787e JB |
90 | /** |
91 | * @var string | |
92 | * | |
93 | * @ORM\Column(name="pocket_consumer_key", type="string", nullable=true) | |
94 | */ | |
95 | private $pocketConsumerKey; | |
96 | ||
a42f38d9 NL |
97 | /** |
98 | * @var int | |
99 | * | |
3ef75cc4 | 100 | * @ORM\Column(name="action_mark_as_read", type="integer", nullable=true, options={"default" = 0}) |
a42f38d9 NL |
101 | */ |
102 | private $actionMarkAsRead; | |
103 | ||
9f01d0fd NL |
104 | /** |
105 | * @var int | |
106 | * | |
9aa99128 | 107 | * @ORM\Column(name="list_mode", type="integer", nullable=true) |
9f01d0fd | 108 | */ |
9aa99128 | 109 | private $listMode; |
9f01d0fd | 110 | |
4d85d7e9 | 111 | /** |
1210dae1 | 112 | * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config") |
4d85d7e9 J |
113 | */ |
114 | private $user; | |
115 | ||
ac9fec61 KG |
116 | /** |
117 | * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\TaggingRule", mappedBy="config", cascade={"remove"}) | |
752b90d1 | 118 | * @ORM\OrderBy({"id" = "ASC"}) |
ac9fec61 KG |
119 | */ |
120 | private $taggingRules; | |
121 | ||
c675bd11 KD |
122 | /** |
123 | * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\IgnoreOriginUserRule", mappedBy="config", cascade={"remove"}) | |
124 | * @ORM\OrderBy({"id" = "ASC"}) | |
125 | */ | |
126 | private $ignoreOriginRules; | |
127 | ||
4d85d7e9 J |
128 | /* |
129 | * @param User $user | |
130 | */ | |
8eedc8cf | 131 | public function __construct(User $user) |
4d85d7e9 J |
132 | { |
133 | $this->user = $user; | |
ac9fec61 | 134 | $this->taggingRules = new ArrayCollection(); |
c675bd11 | 135 | $this->ignoreOriginRules = new ArrayCollection(); |
4d85d7e9 | 136 | } |
9d50517c | 137 | |
9d50517c | 138 | /** |
4346a860 | 139 | * Get id. |
9d50517c | 140 | * |
4346a860 | 141 | * @return int |
9d50517c NL |
142 | */ |
143 | public function getId() | |
144 | { | |
145 | return $this->id; | |
146 | } | |
147 | ||
148 | /** | |
4346a860 JB |
149 | * Set theme. |
150 | * | |
151 | * @param string $theme | |
9d50517c | 152 | * |
9d50517c NL |
153 | * @return Config |
154 | */ | |
4d85d7e9 | 155 | public function setTheme($theme) |
9d50517c | 156 | { |
4d85d7e9 | 157 | $this->theme = $theme; |
9d50517c NL |
158 | |
159 | return $this; | |
160 | } | |
161 | ||
162 | /** | |
4346a860 | 163 | * Get theme. |
9d50517c | 164 | * |
7df80cb3 | 165 | * @return string |
9d50517c | 166 | */ |
4d85d7e9 | 167 | public function getTheme() |
9d50517c | 168 | { |
4d85d7e9 | 169 | return $this->theme; |
9d50517c NL |
170 | } |
171 | ||
172 | /** | |
4346a860 JB |
173 | * Set itemsPerPage. |
174 | * | |
175 | * @param int $itemsPerPage | |
9d50517c | 176 | * |
9d50517c NL |
177 | * @return Config |
178 | */ | |
4d85d7e9 | 179 | public function setItemsPerPage($itemsPerPage) |
9d50517c | 180 | { |
0c83fd59 | 181 | $this->itemsPerPage = $itemsPerPage; |
9d50517c NL |
182 | |
183 | return $this; | |
184 | } | |
185 | ||
186 | /** | |
4346a860 | 187 | * Get itemsPerPage. |
4d85d7e9 | 188 | * |
4346a860 | 189 | * @return int |
4d85d7e9 J |
190 | */ |
191 | public function getItemsPerPage() | |
192 | { | |
0c83fd59 | 193 | return $this->itemsPerPage; |
4d85d7e9 J |
194 | } |
195 | ||
196 | /** | |
4346a860 JB |
197 | * Set language. |
198 | * | |
199 | * @param string $language | |
4d85d7e9 | 200 | * |
4d85d7e9 J |
201 | * @return Config |
202 | */ | |
203 | public function setLanguage($language) | |
204 | { | |
205 | $this->language = $language; | |
206 | ||
207 | return $this; | |
208 | } | |
209 | ||
210 | /** | |
4346a860 | 211 | * Get language. |
9d50517c | 212 | * |
7df80cb3 | 213 | * @return string |
9d50517c | 214 | */ |
4d85d7e9 J |
215 | public function getLanguage() |
216 | { | |
217 | return $this->language; | |
218 | } | |
219 | ||
220 | /** | |
4346a860 JB |
221 | * Set user. |
222 | * | |
1210dae1 | 223 | * @param User $user |
4d85d7e9 | 224 | * |
4d85d7e9 J |
225 | * @return Config |
226 | */ | |
8eedc8cf | 227 | public function setUser(User $user = null) |
4d85d7e9 J |
228 | { |
229 | $this->user = $user; | |
230 | ||
231 | return $this; | |
232 | } | |
233 | ||
234 | /** | |
4346a860 | 235 | * Get user. |
4d85d7e9 | 236 | * |
1210dae1 | 237 | * @return User |
4d85d7e9 J |
238 | */ |
239 | public function getUser() | |
9d50517c | 240 | { |
4d85d7e9 | 241 | return $this->user; |
9d50517c | 242 | } |
0c83fd59 J |
243 | |
244 | /** | |
531c8d0a | 245 | * Set feed Token. |
4346a860 | 246 | * |
531c8d0a | 247 | * @param string $feedToken |
0c83fd59 | 248 | * |
0c83fd59 J |
249 | * @return Config |
250 | */ | |
531c8d0a | 251 | public function setFeedToken($feedToken) |
0c83fd59 | 252 | { |
531c8d0a | 253 | $this->feedToken = $feedToken; |
0c83fd59 J |
254 | |
255 | return $this; | |
256 | } | |
257 | ||
258 | /** | |
531c8d0a | 259 | * Get feedToken. |
0c83fd59 J |
260 | * |
261 | * @return string | |
262 | */ | |
531c8d0a | 263 | public function getFeedToken() |
0c83fd59 | 264 | { |
531c8d0a | 265 | return $this->feedToken; |
0c83fd59 J |
266 | } |
267 | ||
268 | /** | |
531c8d0a | 269 | * Set Feed Limit. |
4346a860 | 270 | * |
531c8d0a | 271 | * @param int $feedLimit |
0c83fd59 | 272 | * |
0c83fd59 J |
273 | * @return Config |
274 | */ | |
531c8d0a | 275 | public function setFeedLimit($feedLimit) |
0c83fd59 | 276 | { |
531c8d0a | 277 | $this->feedLimit = $feedLimit; |
0c83fd59 J |
278 | |
279 | return $this; | |
280 | } | |
281 | ||
282 | /** | |
531c8d0a | 283 | * Get Feed Limit. |
0c83fd59 | 284 | * |
8eedc8cf | 285 | * @return int |
0c83fd59 | 286 | */ |
531c8d0a | 287 | public function getFeedLimit() |
0c83fd59 | 288 | { |
531c8d0a | 289 | return $this->feedLimit; |
0c83fd59 | 290 | } |
ac9fec61 | 291 | |
bca54859 NL |
292 | /** |
293 | * Set readingSpeed. | |
294 | * | |
1b64a84b | 295 | * @param float $readingSpeed |
bca54859 NL |
296 | * |
297 | * @return Config | |
298 | */ | |
299 | public function setReadingSpeed($readingSpeed) | |
300 | { | |
301 | $this->readingSpeed = $readingSpeed; | |
302 | ||
303 | return $this; | |
304 | } | |
305 | ||
306 | /** | |
307 | * Get readingSpeed. | |
308 | * | |
1b64a84b | 309 | * @return float |
bca54859 NL |
310 | */ |
311 | public function getReadingSpeed() | |
312 | { | |
313 | return $this->readingSpeed; | |
314 | } | |
315 | ||
ebe0787e JB |
316 | /** |
317 | * Set pocketConsumerKey. | |
318 | * | |
319 | * @param string $pocketConsumerKey | |
320 | * | |
321 | * @return Config | |
322 | */ | |
323 | public function setPocketConsumerKey($pocketConsumerKey) | |
324 | { | |
325 | $this->pocketConsumerKey = $pocketConsumerKey; | |
326 | ||
327 | return $this; | |
328 | } | |
329 | ||
330 | /** | |
331 | * Get pocketConsumerKey. | |
332 | * | |
333 | * @return string | |
334 | */ | |
335 | public function getPocketConsumerKey() | |
336 | { | |
337 | return $this->pocketConsumerKey; | |
338 | } | |
339 | ||
a42f38d9 NL |
340 | /** |
341 | * @return int | |
342 | */ | |
343 | public function getActionMarkAsRead() | |
344 | { | |
345 | return $this->actionMarkAsRead; | |
346 | } | |
347 | ||
348 | /** | |
349 | * @param int $actionMarkAsRead | |
350 | * | |
351 | * @return Config | |
352 | */ | |
353 | public function setActionMarkAsRead($actionMarkAsRead) | |
354 | { | |
355 | $this->actionMarkAsRead = $actionMarkAsRead; | |
356 | ||
357 | return $this; | |
358 | } | |
359 | ||
9f01d0fd NL |
360 | /** |
361 | * @return int | |
362 | */ | |
9aa99128 | 363 | public function getListMode() |
9f01d0fd | 364 | { |
9aa99128 | 365 | return $this->listMode; |
9f01d0fd NL |
366 | } |
367 | ||
368 | /** | |
9aa99128 | 369 | * @param int $listMode |
9f01d0fd NL |
370 | * |
371 | * @return Config | |
372 | */ | |
9aa99128 | 373 | public function setListMode($listMode) |
9f01d0fd | 374 | { |
9aa99128 | 375 | $this->listMode = $listMode; |
9f01d0fd NL |
376 | |
377 | return $this; | |
378 | } | |
379 | ||
ac9fec61 | 380 | /** |
ac9fec61 KG |
381 | * @return Config |
382 | */ | |
383 | public function addTaggingRule(TaggingRule $rule) | |
384 | { | |
385 | $this->taggingRules[] = $rule; | |
386 | ||
387 | return $this; | |
388 | } | |
389 | ||
390 | /** | |
391 | * @return ArrayCollection<TaggingRule> | |
392 | */ | |
393 | public function getTaggingRules() | |
394 | { | |
395 | return $this->taggingRules; | |
396 | } | |
c675bd11 KD |
397 | |
398 | /** | |
399 | * @return Config | |
400 | */ | |
401 | public function addIgnoreOriginRule(IgnoreOriginUserRule $rule) | |
402 | { | |
403 | $this->ignoreOriginRules[] = $rule; | |
404 | ||
405 | return $this; | |
406 | } | |
407 | ||
408 | /** | |
409 | * @return ArrayCollection<IgnoreOriginUserRule> | |
410 | */ | |
411 | public function getIgnoreOriginRules() | |
412 | { | |
413 | return $this->ignoreOriginRules; | |
414 | } | |
9d50517c | 415 | } |