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