]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | namespace Wallabag\CoreBundle\Entity; | |
4 | ||
5 | use Doctrine\Common\Collections\ArrayCollection; | |
6 | use Doctrine\ORM\Mapping as ORM; | |
7 | use Symfony\Component\Validator\Constraints as Assert; | |
8 | use Wallabag\UserBundle\Entity\User; | |
9 | ||
10 | /** | |
11 | * Config. | |
12 | * | |
13 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\ConfigRepository") | |
14 | * @ORM\Table( | |
15 | * name="`config`", | |
16 | * indexes={ | |
17 | * @ORM\Index(name="config_feed_token", columns={"feed_token"}, options={"lengths"={255}}), | |
18 | * } | |
19 | * ) | |
20 | */ | |
21 | class Config | |
22 | { | |
23 | const REDIRECT_TO_HOMEPAGE = 0; | |
24 | const REDIRECT_TO_CURRENT_PAGE = 1; | |
25 | ||
26 | /** | |
27 | * @var int | |
28 | * | |
29 | * @ORM\Column(name="id", type="integer") | |
30 | * @ORM\Id | |
31 | * @ORM\GeneratedValue(strategy="AUTO") | |
32 | */ | |
33 | private $id; | |
34 | ||
35 | /** | |
36 | * @var string | |
37 | * | |
38 | * @Assert\NotBlank() | |
39 | * @ORM\Column(name="theme", type="string", nullable=false) | |
40 | */ | |
41 | private $theme; | |
42 | ||
43 | /** | |
44 | * @var int | |
45 | * | |
46 | * @Assert\NotBlank() | |
47 | * @Assert\Range( | |
48 | * min = 1, | |
49 | * max = 100000, | |
50 | * maxMessage = "validator.item_per_page_too_high" | |
51 | * ) | |
52 | * @ORM\Column(name="items_per_page", type="integer", nullable=false) | |
53 | */ | |
54 | private $itemsPerPage; | |
55 | ||
56 | /** | |
57 | * @var string | |
58 | * | |
59 | * @Assert\NotBlank() | |
60 | * @ORM\Column(name="language", type="string", nullable=false) | |
61 | */ | |
62 | private $language; | |
63 | ||
64 | /** | |
65 | * @var string | |
66 | * | |
67 | * @ORM\Column(name="feed_token", type="string", nullable=true) | |
68 | */ | |
69 | private $feedToken; | |
70 | ||
71 | /** | |
72 | * @var int | |
73 | * | |
74 | * @ORM\Column(name="feed_limit", type="integer", nullable=true) | |
75 | * @Assert\Range( | |
76 | * min = 1, | |
77 | * max = 100000, | |
78 | * maxMessage = "validator.feed_limit_too_high" | |
79 | * ) | |
80 | */ | |
81 | private $feedLimit; | |
82 | ||
83 | /** | |
84 | * @var float | |
85 | * | |
86 | * @ORM\Column(name="reading_speed", type="float", nullable=true) | |
87 | */ | |
88 | private $readingSpeed; | |
89 | ||
90 | /** | |
91 | * @var string | |
92 | * | |
93 | * @ORM\Column(name="pocket_consumer_key", type="string", nullable=true) | |
94 | */ | |
95 | private $pocketConsumerKey; | |
96 | ||
97 | /** | |
98 | * @var int | |
99 | * | |
100 | * @ORM\Column(name="action_mark_as_read", type="integer", nullable=true, options={"default" = 0}) | |
101 | */ | |
102 | private $actionMarkAsRead; | |
103 | ||
104 | /** | |
105 | * @var int | |
106 | * | |
107 | * @ORM\Column(name="list_mode", type="integer", nullable=true) | |
108 | */ | |
109 | private $listMode; | |
110 | ||
111 | /** | |
112 | * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config") | |
113 | */ | |
114 | private $user; | |
115 | ||
116 | /** | |
117 | * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\TaggingRule", mappedBy="config", cascade={"remove"}) | |
118 | * @ORM\OrderBy({"id" = "ASC"}) | |
119 | */ | |
120 | private $taggingRules; | |
121 | ||
122 | /* | |
123 | * @param User $user | |
124 | */ | |
125 | public function __construct(User $user) | |
126 | { | |
127 | $this->user = $user; | |
128 | $this->taggingRules = new ArrayCollection(); | |
129 | } | |
130 | ||
131 | /** | |
132 | * Get id. | |
133 | * | |
134 | * @return int | |
135 | */ | |
136 | public function getId() | |
137 | { | |
138 | return $this->id; | |
139 | } | |
140 | ||
141 | /** | |
142 | * Set theme. | |
143 | * | |
144 | * @param string $theme | |
145 | * | |
146 | * @return Config | |
147 | */ | |
148 | public function setTheme($theme) | |
149 | { | |
150 | $this->theme = $theme; | |
151 | ||
152 | return $this; | |
153 | } | |
154 | ||
155 | /** | |
156 | * Get theme. | |
157 | * | |
158 | * @return string | |
159 | */ | |
160 | public function getTheme() | |
161 | { | |
162 | return $this->theme; | |
163 | } | |
164 | ||
165 | /** | |
166 | * Set itemsPerPage. | |
167 | * | |
168 | * @param int $itemsPerPage | |
169 | * | |
170 | * @return Config | |
171 | */ | |
172 | public function setItemsPerPage($itemsPerPage) | |
173 | { | |
174 | $this->itemsPerPage = $itemsPerPage; | |
175 | ||
176 | return $this; | |
177 | } | |
178 | ||
179 | /** | |
180 | * Get itemsPerPage. | |
181 | * | |
182 | * @return int | |
183 | */ | |
184 | public function getItemsPerPage() | |
185 | { | |
186 | return $this->itemsPerPage; | |
187 | } | |
188 | ||
189 | /** | |
190 | * Set language. | |
191 | * | |
192 | * @param string $language | |
193 | * | |
194 | * @return Config | |
195 | */ | |
196 | public function setLanguage($language) | |
197 | { | |
198 | $this->language = $language; | |
199 | ||
200 | return $this; | |
201 | } | |
202 | ||
203 | /** | |
204 | * Get language. | |
205 | * | |
206 | * @return string | |
207 | */ | |
208 | public function getLanguage() | |
209 | { | |
210 | return $this->language; | |
211 | } | |
212 | ||
213 | /** | |
214 | * Set user. | |
215 | * | |
216 | * @param User $user | |
217 | * | |
218 | * @return Config | |
219 | */ | |
220 | public function setUser(User $user = null) | |
221 | { | |
222 | $this->user = $user; | |
223 | ||
224 | return $this; | |
225 | } | |
226 | ||
227 | /** | |
228 | * Get user. | |
229 | * | |
230 | * @return User | |
231 | */ | |
232 | public function getUser() | |
233 | { | |
234 | return $this->user; | |
235 | } | |
236 | ||
237 | /** | |
238 | * Set feed Token. | |
239 | * | |
240 | * @param string $feedToken | |
241 | * | |
242 | * @return Config | |
243 | */ | |
244 | public function setFeedToken($feedToken) | |
245 | { | |
246 | $this->feedToken = $feedToken; | |
247 | ||
248 | return $this; | |
249 | } | |
250 | ||
251 | /** | |
252 | * Get feedToken. | |
253 | * | |
254 | * @return string | |
255 | */ | |
256 | public function getFeedToken() | |
257 | { | |
258 | return $this->feedToken; | |
259 | } | |
260 | ||
261 | /** | |
262 | * Set Feed Limit. | |
263 | * | |
264 | * @param int $feedLimit | |
265 | * | |
266 | * @return Config | |
267 | */ | |
268 | public function setFeedLimit($feedLimit) | |
269 | { | |
270 | $this->feedLimit = $feedLimit; | |
271 | ||
272 | return $this; | |
273 | } | |
274 | ||
275 | /** | |
276 | * Get Feed Limit. | |
277 | * | |
278 | * @return int | |
279 | */ | |
280 | public function getFeedLimit() | |
281 | { | |
282 | return $this->feedLimit; | |
283 | } | |
284 | ||
285 | /** | |
286 | * Set readingSpeed. | |
287 | * | |
288 | * @param float $readingSpeed | |
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 | * | |
302 | * @return float | |
303 | */ | |
304 | public function getReadingSpeed() | |
305 | { | |
306 | return $this->readingSpeed; | |
307 | } | |
308 | ||
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 | ||
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 | ||
353 | /** | |
354 | * @return int | |
355 | */ | |
356 | public function getListMode() | |
357 | { | |
358 | return $this->listMode; | |
359 | } | |
360 | ||
361 | /** | |
362 | * @param int $listMode | |
363 | * | |
364 | * @return Config | |
365 | */ | |
366 | public function setListMode($listMode) | |
367 | { | |
368 | $this->listMode = $listMode; | |
369 | ||
370 | return $this; | |
371 | } | |
372 | ||
373 | /** | |
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 | } | |
390 | } |