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