]>
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 | ||
4d85d7e9 J |
122 | /* |
123 | * @param User $user | |
124 | */ | |
8eedc8cf | 125 | public function __construct(User $user) |
4d85d7e9 J |
126 | { |
127 | $this->user = $user; | |
ac9fec61 | 128 | $this->taggingRules = new ArrayCollection(); |
4d85d7e9 | 129 | } |
9d50517c | 130 | |
9d50517c | 131 | /** |
4346a860 | 132 | * Get id. |
9d50517c | 133 | * |
4346a860 | 134 | * @return int |
9d50517c NL |
135 | */ |
136 | public function getId() | |
137 | { | |
138 | return $this->id; | |
139 | } | |
140 | ||
141 | /** | |
4346a860 JB |
142 | * Set theme. |
143 | * | |
144 | * @param string $theme | |
9d50517c | 145 | * |
9d50517c NL |
146 | * @return Config |
147 | */ | |
4d85d7e9 | 148 | public function setTheme($theme) |
9d50517c | 149 | { |
4d85d7e9 | 150 | $this->theme = $theme; |
9d50517c NL |
151 | |
152 | return $this; | |
153 | } | |
154 | ||
155 | /** | |
4346a860 | 156 | * Get theme. |
9d50517c | 157 | * |
7df80cb3 | 158 | * @return string |
9d50517c | 159 | */ |
4d85d7e9 | 160 | public function getTheme() |
9d50517c | 161 | { |
4d85d7e9 | 162 | return $this->theme; |
9d50517c NL |
163 | } |
164 | ||
165 | /** | |
4346a860 JB |
166 | * Set itemsPerPage. |
167 | * | |
168 | * @param int $itemsPerPage | |
9d50517c | 169 | * |
9d50517c NL |
170 | * @return Config |
171 | */ | |
4d85d7e9 | 172 | public function setItemsPerPage($itemsPerPage) |
9d50517c | 173 | { |
0c83fd59 | 174 | $this->itemsPerPage = $itemsPerPage; |
9d50517c NL |
175 | |
176 | return $this; | |
177 | } | |
178 | ||
179 | /** | |
4346a860 | 180 | * Get itemsPerPage. |
4d85d7e9 | 181 | * |
4346a860 | 182 | * @return int |
4d85d7e9 J |
183 | */ |
184 | public function getItemsPerPage() | |
185 | { | |
0c83fd59 | 186 | return $this->itemsPerPage; |
4d85d7e9 J |
187 | } |
188 | ||
189 | /** | |
4346a860 JB |
190 | * Set language. |
191 | * | |
192 | * @param string $language | |
4d85d7e9 | 193 | * |
4d85d7e9 J |
194 | * @return Config |
195 | */ | |
196 | public function setLanguage($language) | |
197 | { | |
198 | $this->language = $language; | |
199 | ||
200 | return $this; | |
201 | } | |
202 | ||
203 | /** | |
4346a860 | 204 | * Get language. |
9d50517c | 205 | * |
7df80cb3 | 206 | * @return string |
9d50517c | 207 | */ |
4d85d7e9 J |
208 | public function getLanguage() |
209 | { | |
210 | return $this->language; | |
211 | } | |
212 | ||
213 | /** | |
4346a860 JB |
214 | * Set user. |
215 | * | |
1210dae1 | 216 | * @param User $user |
4d85d7e9 | 217 | * |
4d85d7e9 J |
218 | * @return Config |
219 | */ | |
8eedc8cf | 220 | public function setUser(User $user = null) |
4d85d7e9 J |
221 | { |
222 | $this->user = $user; | |
223 | ||
224 | return $this; | |
225 | } | |
226 | ||
227 | /** | |
4346a860 | 228 | * Get user. |
4d85d7e9 | 229 | * |
1210dae1 | 230 | * @return User |
4d85d7e9 J |
231 | */ |
232 | public function getUser() | |
9d50517c | 233 | { |
4d85d7e9 | 234 | return $this->user; |
9d50517c | 235 | } |
0c83fd59 J |
236 | |
237 | /** | |
531c8d0a | 238 | * Set feed Token. |
4346a860 | 239 | * |
531c8d0a | 240 | * @param string $feedToken |
0c83fd59 | 241 | * |
0c83fd59 J |
242 | * @return Config |
243 | */ | |
531c8d0a | 244 | public function setFeedToken($feedToken) |
0c83fd59 | 245 | { |
531c8d0a | 246 | $this->feedToken = $feedToken; |
0c83fd59 J |
247 | |
248 | return $this; | |
249 | } | |
250 | ||
251 | /** | |
531c8d0a | 252 | * Get feedToken. |
0c83fd59 J |
253 | * |
254 | * @return string | |
255 | */ | |
531c8d0a | 256 | public function getFeedToken() |
0c83fd59 | 257 | { |
531c8d0a | 258 | return $this->feedToken; |
0c83fd59 J |
259 | } |
260 | ||
261 | /** | |
531c8d0a | 262 | * Set Feed Limit. |
4346a860 | 263 | * |
531c8d0a | 264 | * @param int $feedLimit |
0c83fd59 | 265 | * |
0c83fd59 J |
266 | * @return Config |
267 | */ | |
531c8d0a | 268 | public function setFeedLimit($feedLimit) |
0c83fd59 | 269 | { |
531c8d0a | 270 | $this->feedLimit = $feedLimit; |
0c83fd59 J |
271 | |
272 | return $this; | |
273 | } | |
274 | ||
275 | /** | |
531c8d0a | 276 | * Get Feed Limit. |
0c83fd59 | 277 | * |
8eedc8cf | 278 | * @return int |
0c83fd59 | 279 | */ |
531c8d0a | 280 | public function getFeedLimit() |
0c83fd59 | 281 | { |
531c8d0a | 282 | return $this->feedLimit; |
0c83fd59 | 283 | } |
ac9fec61 | 284 | |
bca54859 NL |
285 | /** |
286 | * Set readingSpeed. | |
287 | * | |
1b64a84b | 288 | * @param float $readingSpeed |
bca54859 NL |
289 | * |
290 | * @return Config | |
291 | */ | |
292 | public function setReadingSpeed($readingSpeed) | |
293 | { | |
294 | $this->readingSpeed = $readingSpeed; | |
295 | ||
296 | return $this; | |
297 | } | |
298 | ||
299 | /** | |
300 | * Get readingSpeed. | |
301 | * | |
1b64a84b | 302 | * @return float |
bca54859 NL |
303 | */ |
304 | public function getReadingSpeed() | |
305 | { | |
306 | return $this->readingSpeed; | |
307 | } | |
308 | ||
ebe0787e JB |
309 | /** |
310 | * Set pocketConsumerKey. | |
311 | * | |
312 | * @param string $pocketConsumerKey | |
313 | * | |
314 | * @return Config | |
315 | */ | |
316 | public function setPocketConsumerKey($pocketConsumerKey) | |
317 | { | |
318 | $this->pocketConsumerKey = $pocketConsumerKey; | |
319 | ||
320 | return $this; | |
321 | } | |
322 | ||
323 | /** | |
324 | * Get pocketConsumerKey. | |
325 | * | |
326 | * @return string | |
327 | */ | |
328 | public function getPocketConsumerKey() | |
329 | { | |
330 | return $this->pocketConsumerKey; | |
331 | } | |
332 | ||
a42f38d9 NL |
333 | /** |
334 | * @return int | |
335 | */ | |
336 | public function getActionMarkAsRead() | |
337 | { | |
338 | return $this->actionMarkAsRead; | |
339 | } | |
340 | ||
341 | /** | |
342 | * @param int $actionMarkAsRead | |
343 | * | |
344 | * @return Config | |
345 | */ | |
346 | public function setActionMarkAsRead($actionMarkAsRead) | |
347 | { | |
348 | $this->actionMarkAsRead = $actionMarkAsRead; | |
349 | ||
350 | return $this; | |
351 | } | |
352 | ||
9f01d0fd NL |
353 | /** |
354 | * @return int | |
355 | */ | |
9aa99128 | 356 | public function getListMode() |
9f01d0fd | 357 | { |
9aa99128 | 358 | return $this->listMode; |
9f01d0fd NL |
359 | } |
360 | ||
361 | /** | |
9aa99128 | 362 | * @param int $listMode |
9f01d0fd NL |
363 | * |
364 | * @return Config | |
365 | */ | |
9aa99128 | 366 | public function setListMode($listMode) |
9f01d0fd | 367 | { |
9aa99128 | 368 | $this->listMode = $listMode; |
9f01d0fd NL |
369 | |
370 | return $this; | |
371 | } | |
372 | ||
ac9fec61 | 373 | /** |
ac9fec61 KG |
374 | * @return Config |
375 | */ | |
376 | public function addTaggingRule(TaggingRule $rule) | |
377 | { | |
378 | $this->taggingRules[] = $rule; | |
379 | ||
380 | return $this; | |
381 | } | |
382 | ||
383 | /** | |
384 | * @return ArrayCollection<TaggingRule> | |
385 | */ | |
386 | public function getTaggingRules() | |
387 | { | |
388 | return $this->taggingRules; | |
389 | } | |
9d50517c | 390 | } |