Completed
Push — master ( a3587c...b04bc5 )
by Luis Ramón
02:12
created

Entry::setPosition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/*
3
  ÁTICA - Aplicación web para la gestión documental de centros educativos
4
5
  Copyright (C) 2015-2017: Luis Ramón López López
6
7
  This program is free software: you can redistribute it and/or modify
8
  it under the terms of the GNU Affero General Public License as published by
9
  the Free Software Foundation, either version 3 of the License, or
10
  (at your option) any later version.
11
12
  This program is distributed in the hope that it will be useful,
13
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  GNU Affero General Public License for more details.
16
17
  You should have received a copy of the GNU Affero General Public License
18
  along with this program.  If not, see [http://www.gnu.org/licenses/].
19
*/
20
21
namespace AppBundle\Entity\Documentation;
22
23
use AppBundle\Entity\Element;
24
use AppBundle\Entity\HistoricPeriod;
25
use AppBundle\Entity\Traits\UserBlameableTrait;
26
use Doctrine\Common\Collections\Collection;
27
use Gedmo\Mapping\Annotation as Gedmo;
28
use Doctrine\ORM\Mapping as ORM;
29
use Gedmo\Timestampable\Traits\TimestampableEntity;
30
31
/**
32
 * @ORM\Entity(repositoryClass="Gedmo\Sortable\Entity\Repository\SortableRepository")
33
 * @ORM\Table(name="documentation_entry")
34
 */
35
class Entry
36
{
37
    const STATUS_APPROVED = 2;
38
    const STATUS_DRAFT = 0;
39
    const STATUS_RETIRED = 6;
40
41
    use TimestampableEntity;
42
    use UserBlameableTrait;
43
44
    /**
45
     * @ORM\Id()
46
     * @ORM\GeneratedValue(strategy="AUTO")
47
     * @ORM\Column(type="integer")
48
     * @var int
49
     */
50
    private $id;
51
52
    /**
53
     * @ORM\Column(type="string")
54
     * @var string
55
     */
56
    private $name;
57
58
    /**
59
     * @ORM\Column(type="text", nullable=true)
60
     * @var string
61
     */
62
    private $description;
63
64
    /**
65
     * @Gedmo\SortablePosition()
66
     * @ORM\Column(type="integer")
67
     * @var int
68
     */
69
    private $position;
70
71
    /**
72
     * @Gedmo\SortableGroup()
73
     * @ORM\ManyToOne(targetEntity="Folder", inversedBy="entries")
74
     * @ORM\JoinColumn(nullable=false)
75
     * @var Folder
76
     */
77
    private $folder;
78
79
    /**
80
     * @Gedmo\SortableGroup()
81
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\HistoricPeriod")
82
     * @ORM\JoinColumn(nullable=true)
83
     * @var HistoricPeriod
84
     */
85
    private $archivedPeriod;
86
87
    /**
88
     * @ORM\ManyToOne(targetEntity="Entry")
89
     * @ORM\JoinColumn(nullable=true)
90
     * @var Entry
91
     */
92
    private $link;
93
94
    /**
95
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Element")
96
     * @ORM\JoinColumn(nullable=true)
97
     * @var Element
98
     */
99
    private $element;
100
101
    /**
102
     * @ORM\Column(type="datetime", nullable=true)
103
     * @var \DateTime
104
     */
105
    private $retiredAt;
106
107
    /**
108
     * @ORM\OneToMany(targetEntity="Version", mappedBy="entry")
109
     * @ORM\OrderBy({"versionNr": "DESC"})
110
     * @var Collection
111
     */
112
    private $versions;
113
114
    /**
115
     * @ORM\OneToMany(targetEntity="History", mappedBy="entry")
116
     * @ORM\OrderBy({"createdAt": "ASC"})
117
     * @var Collection
118
     */
119
    private $history;
120
121
    /**
122
     * @ORM\OneToOne(targetEntity="Version")
123
     * @var Version
124
     */
125
    private $currentVersion;
126
127
    /**
128
     * @ORM\Column(type="boolean")
129
     * @var bool
130
     */
131
    private $public;
132
133
    /**
134
     * @ORM\Column(type="string", nullable=true)
135
     * @var string
136
     */
137
    private $publicToken;
138
139
    /**
140
     * @ORM\Column(type="integer")
141
     * @var int
142
     */
143
    private $state;
144
145
    /**
146
     * @Gedmo\Timestampable(on="change", field="state")
147
     * @ORM\Column(type="datetime")
148
     * @var \DateTime
149
     */
150
    private $stateChangedAt;
151
152
    /**
153
     * Constructor
154
     */
155
    public function __construct()
156
    {
157
        $this->versions = new \Doctrine\Common\Collections\ArrayCollection();
158
        $this->history = new \Doctrine\Common\Collections\ArrayCollection();
159
        $this->stateChangedAt = new \DateTime();
160
        $this->public = false;
161
    }
162
163
    /**
164
     * Get id
165
     *
166
     * @return integer
167
     */
168
    public function getId()
169
    {
170
        return $this->id;
171
    }
172
173
    /**
174
     * Set name
175
     *
176
     * @param string $name
177
     *
178
     * @return Entry
179
     */
180
    public function setName($name)
181
    {
182
        $this->name = $name;
183
184
        return $this;
185
    }
186
187
    /**
188
     * Get name
189
     *
190
     * @return string
191
     */
192
    public function getName()
193
    {
194
        return $this->name;
195
    }
196
197
    /**
198
     * Set description
199
     *
200
     * @param string $description
201
     *
202
     * @return Entry
203
     */
204
    public function setDescription($description)
205
    {
206
        $this->description = $description;
207
208
        return $this;
209
    }
210
211
    /**
212
     * Get description
213
     *
214
     * @return string
215
     */
216
    public function getDescription()
217
    {
218
        return $this->description;
219
    }
220
221
    /**
222
     * Set position
223
     *
224
     * @param integer $position
225
     *
226
     * @return Entry
227
     */
228
    public function setPosition($position)
229
    {
230
        $this->position = $position;
231
232
        return $this;
233
    }
234
235
    /**
236
     * Get position
237
     *
238
     * @return integer
239
     */
240
    public function getPosition()
241
    {
242
        return $this->position;
243
    }
244
245
    /**
246
     * Set retiredAt
247
     *
248
     * @param \DateTime $retiredAt
249
     *
250
     * @return Entry
251
     */
252
    public function setRetiredAt($retiredAt)
253
    {
254
        $this->retiredAt = $retiredAt;
255
256
        return $this;
257
    }
258
259
    /**
260
     * Get retiredAt
261
     *
262
     * @return \DateTime
263
     */
264
    public function getRetiredAt()
265
    {
266
        return $this->retiredAt;
267
    }
268
269
    /**
270
     * Set folder
271
     *
272
     * @param Folder $folder
273
     *
274
     * @return Entry
275
     */
276
    public function setFolder(Folder $folder)
277
    {
278
        $this->folder = $folder;
279
280
        return $this;
281
    }
282
283
    /**
284
     * Get folder
285
     *
286
     * @return Folder
287
     */
288
    public function getFolder()
289
    {
290
        return $this->folder;
291
    }
292
293
    /**
294
     * Set link
295
     *
296
     * @param Entry $link
297
     *
298
     * @return Entry
299
     */
300
    public function setLink(Entry $link = null)
301
    {
302
        $this->link = $link;
303
304
        return $this;
305
    }
306
307
    /**
308
     * Get link
309
     *
310
     * @return Entry
311
     */
312
    public function getLink()
313
    {
314
        return $this->link;
315
    }
316
317
    /**
318
     * Add version
319
     *
320
     * @param Version $version
321
     *
322
     * @return Entry
323
     */
324
    public function addVersion(Version $version)
325
    {
326
        $this->versions[] = $version;
327
328
        return $this;
329
    }
330
331
    /**
332
     * Remove version
333
     *
334
     * @param Version $version
335
     */
336
    public function removeVersion(Version $version)
337
    {
338
        $this->versions->removeElement($version);
339
    }
340
341
    /**
342
     * Get versions
343
     *
344
     * @return Collection
345
     */
346
    public function getVersions()
347
    {
348
        return $this->versions;
349
    }
350
351
    /**
352
     * Add history
353
     *
354
     * @param History $history
355
     *
356
     * @return Entry
357
     */
358
    public function addHistory(History $history)
359
    {
360
        $this->history[] = $history;
361
362
        return $this;
363
    }
364
365
    /**
366
     * Remove history
367
     *
368
     * @param History $history
369
     */
370
    public function removeHistory(History $history)
371
    {
372
        $this->history->removeElement($history);
373
    }
374
375
    /**
376
     * Get history
377
     *
378
     * @return Collection
379
     */
380
    public function getHistory()
381
    {
382
        return $this->history;
383
    }
384
385
    /**
386
     * Set element
387
     *
388
     * @param Element $element
389
     *
390
     * @return Entry
391
     */
392
    public function setElement(Element $element = null)
393
    {
394
        $this->element = $element;
395
396
        return $this;
397
    }
398
399
    /**
400
     * Get element
401
     *
402
     * @return Element
403
     */
404
    public function getElement()
405
    {
406
        return $this->element;
407
    }
408
409
    /**
410
     * Set archivedPeriod
411
     *
412
     * @param HistoricPeriod $archivedPeriod
413
     *
414
     * @return Entry
415
     */
416
    public function setArchivedPeriod(HistoricPeriod $archivedPeriod = null)
417
    {
418
        $this->archivedPeriod = $archivedPeriod;
419
420
        return $this;
421
    }
422
423
    /**
424
     * Get archivedPeriod
425
     *
426
     * @return HistoricPeriod
427
     */
428
    public function getArchivedPeriod()
429
    {
430
        return $this->archivedPeriod;
431
    }
432
433
    /**
434
     * @return Version
435
     */
436
    public function getCurrentVersion()
437
    {
438
        return $this->currentVersion;
439
    }
440
441
    /**
442
     * @param Version $currentVersion
443
     * @return Entry
444
     */
445
    public function setCurrentVersion($currentVersion = null)
446
    {
447
        $this->currentVersion = $currentVersion;
448
        return $this;
449
    }
450
451
    /**
452
     * Get public
453
     *
454
     * @return bool
455
     */
456
    public function isPublic()
457
    {
458
        return $this->public;
459
    }
460
461
    /**
462
     * Set public
463
     *
464
     * @param bool $public
465
     *
466
     * @return Entry
467
     */
468
    public function setPublic($public)
469
    {
470
        $this->public = $public;
471
        return $this;
472
    }
473
474
    /**
475
     * Get publicToken
476
     *
477
     * @return string
478
     */
479
    public function getPublicToken()
480
    {
481
        return $this->publicToken;
482
    }
483
484
    /**
485
     * Set publicToken
486
     *
487
     * @param string $publicToken
488
     *
489
     * @return Entry
490
     */
491
    public function setPublicToken($publicToken)
492
    {
493
        $this->publicToken = $publicToken;
494
        return $this;
495
    }
496
497
    /**
498
     * Set state
499
     *
500
     * @param integer $state
501
     *
502
     * @return Entry
503
     */
504
    public function setState($state)
505
    {
506
        $this->state = $state;
507
508
        return $this;
509
    }
510
511
    /**
512
     * Get state
513
     *
514
     * @return integer
515
     */
516
    public function getState()
517
    {
518
        return $this->state;
519
    }
520
521
    /**
522
     * Set stateChangedAt
523
     *
524
     * @param \DateTime $stateChangedAt
525
     *
526
     * @return Entry
527
     */
528
    public function setStateChangedAt($stateChangedAt)
529
    {
530
        $this->stateChangedAt = $stateChangedAt;
531
532
        return $this;
533
    }
534
535
    /**
536
     * Get stateChangedAt
537
     *
538
     * @return \DateTime
539
     */
540
    public function getStateChangedAt()
541
    {
542
        return $this->stateChangedAt;
543
    }
544
}
545