Entry::addHistory()   A
last analyzed

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_DRAFT = 0;
38
    const STATUS_REVIEWED = 1;
39
    const STATUS_APPROVED = 2;
40
    const STATUS_RETIRED = 100;
41
42
    use TimestampableEntity;
43
    use UserBlameableTrait;
44
45
    /**
46
     * @ORM\Id()
47
     * @ORM\GeneratedValue(strategy="AUTO")
48
     * @ORM\Column(type="integer")
49
     * @var int
50
     */
51
    private $id;
52
53
    /**
54
     * @ORM\Column(type="string")
55
     * @var string
56
     */
57
    private $name;
58
59
    /**
60
     * @ORM\Column(type="text", nullable=true)
61
     * @var string
62
     */
63
    private $description;
64
65
    /**
66
     * @Gedmo\SortablePosition()
67
     * @ORM\Column(type="integer")
68
     * @var int
69
     */
70
    private $position;
71
72
    /**
73
     * @Gedmo\SortableGroup()
74
     * @ORM\ManyToOne(targetEntity="Folder", inversedBy="entries")
75
     * @ORM\JoinColumn(nullable=false)
76
     * @var Folder
77
     */
78
    private $folder;
79
80
    /**
81
     * @Gedmo\SortableGroup()
82
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\HistoricPeriod")
83
     * @ORM\JoinColumn(nullable=true)
84
     * @var HistoricPeriod
85
     */
86
    private $archivedPeriod;
87
88
    /**
89
     * @ORM\ManyToOne(targetEntity="Entry")
90
     * @ORM\JoinColumn(nullable=true)
91
     * @var Entry
92
     */
93
    private $link;
94
95
    /**
96
     * @Gedmo\SortableGroup()
97
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Element")
98
     * @ORM\JoinColumn(nullable=true)
99
     * @var Element
100
     */
101
    private $element;
102
103
    /**
104
     * @ORM\Column(type="datetime", nullable=true)
105
     * @var \DateTime
106
     */
107
    private $retiredAt;
108
109
    /**
110
     * @ORM\OneToMany(targetEntity="Version", mappedBy="entry")
111
     * @ORM\OrderBy({"versionNr": "DESC"})
112
     * @var Collection
113
     */
114
    private $versions;
115
116
    /**
117
     * @ORM\OneToMany(targetEntity="History", mappedBy="entry")
118
     * @ORM\OrderBy({"createdAt": "ASC"})
119
     * @var Collection
120
     */
121
    private $history;
122
123
    /**
124
     * @ORM\OneToOne(targetEntity="Version")
125
     * @var Version
126
     */
127
    private $currentVersion;
128
129
    /**
130
     * @ORM\Column(type="boolean")
131
     * @var bool
132
     */
133
    private $public;
134
135
    /**
136
     * @ORM\Column(type="string", nullable=true)
137
     * @var string
138
     */
139
    private $publicToken;
140
141
    /**
142
     * @ORM\Column(type="integer")
143
     * @var int
144
     */
145
    private $state;
146
147
    /**
148
     * @Gedmo\Timestampable(on="change", field="state")
149
     * @ORM\Column(type="datetime")
150
     * @var \DateTime
151
     */
152
    private $stateChangedAt;
153
154
    /**
155
     * Constructor
156
     */
157
    public function __construct()
158
    {
159
        $this->versions = new \Doctrine\Common\Collections\ArrayCollection();
160
        $this->history = new \Doctrine\Common\Collections\ArrayCollection();
161
        $this->stateChangedAt = new \DateTime();
162
        $this->public = false;
163
    }
164
165
    /**
166
     * Get id
167
     *
168
     * @return integer
169
     */
170
    public function getId()
171
    {
172
        return $this->id;
173
    }
174
175
    /**
176
     * Set name
177
     *
178
     * @param string $name
179
     *
180
     * @return Entry
181
     */
182
    public function setName($name)
183
    {
184
        $this->name = $name;
185
186
        return $this;
187
    }
188
189
    /**
190
     * Get name
191
     *
192
     * @return string
193
     */
194
    public function getName()
195
    {
196
        return $this->name;
197
    }
198
199
    /**
200
     * Set description
201
     *
202
     * @param string $description
203
     *
204
     * @return Entry
205
     */
206
    public function setDescription($description)
207
    {
208
        $this->description = $description;
209
210
        return $this;
211
    }
212
213
    /**
214
     * Get description
215
     *
216
     * @return string
217
     */
218
    public function getDescription()
219
    {
220
        return $this->description;
221
    }
222
223
    /**
224
     * Set position
225
     *
226
     * @param integer $position
227
     *
228
     * @return Entry
229
     */
230
    public function setPosition($position)
231
    {
232
        $this->position = $position;
233
234
        return $this;
235
    }
236
237
    /**
238
     * Get position
239
     *
240
     * @return integer
241
     */
242
    public function getPosition()
243
    {
244
        return $this->position;
245
    }
246
247
    /**
248
     * Set retiredAt
249
     *
250
     * @param \DateTime $retiredAt
251
     *
252
     * @return Entry
253
     */
254
    public function setRetiredAt($retiredAt)
255
    {
256
        $this->retiredAt = $retiredAt;
257
258
        return $this;
259
    }
260
261
    /**
262
     * Get retiredAt
263
     *
264
     * @return \DateTime
265
     */
266
    public function getRetiredAt()
267
    {
268
        return $this->retiredAt;
269
    }
270
271
    /**
272
     * Set folder
273
     *
274
     * @param Folder $folder
275
     *
276
     * @return Entry
277
     */
278
    public function setFolder(Folder $folder)
279
    {
280
        $this->folder = $folder;
281
282
        return $this;
283
    }
284
285
    /**
286
     * Get folder
287
     *
288
     * @return Folder
289
     */
290
    public function getFolder()
291
    {
292
        return $this->folder;
293
    }
294
295
    /**
296
     * Set link
297
     *
298
     * @param Entry $link
299
     *
300
     * @return Entry
301
     */
302
    public function setLink(Entry $link = null)
303
    {
304
        $this->link = $link;
305
306
        return $this;
307
    }
308
309
    /**
310
     * Get link
311
     *
312
     * @return Entry
313
     */
314
    public function getLink()
315
    {
316
        return $this->link;
317
    }
318
319
    /**
320
     * Add version
321
     *
322
     * @param Version $version
323
     *
324
     * @return Entry
325
     */
326
    public function addVersion(Version $version)
327
    {
328
        $this->versions[] = $version;
329
330
        return $this;
331
    }
332
333
    /**
334
     * Remove version
335
     *
336
     * @param Version $version
337
     */
338
    public function removeVersion(Version $version)
339
    {
340
        $this->versions->removeElement($version);
341
    }
342
343
    /**
344
     * Get versions
345
     *
346
     * @return Collection
347
     */
348
    public function getVersions()
349
    {
350
        return $this->versions;
351
    }
352
353
    /**
354
     * Add history
355
     *
356
     * @param History $history
357
     *
358
     * @return Entry
359
     */
360
    public function addHistory(History $history)
361
    {
362
        $this->history[] = $history;
363
364
        return $this;
365
    }
366
367
    /**
368
     * Remove history
369
     *
370
     * @param History $history
371
     */
372
    public function removeHistory(History $history)
373
    {
374
        $this->history->removeElement($history);
375
    }
376
377
    /**
378
     * Get history
379
     *
380
     * @return Collection
381
     */
382
    public function getHistory()
383
    {
384
        return $this->history;
385
    }
386
387
    /**
388
     * Set element
389
     *
390
     * @param Element $element
391
     *
392
     * @return Entry
393
     */
394
    public function setElement(Element $element = null)
395
    {
396
        $this->element = $element;
397
398
        return $this;
399
    }
400
401
    /**
402
     * Get element
403
     *
404
     * @return Element
405
     */
406
    public function getElement()
407
    {
408
        return $this->element;
409
    }
410
411
    /**
412
     * Set archivedPeriod
413
     *
414
     * @param HistoricPeriod $archivedPeriod
415
     *
416
     * @return Entry
417
     */
418
    public function setArchivedPeriod(HistoricPeriod $archivedPeriod = null)
419
    {
420
        $this->archivedPeriod = $archivedPeriod;
421
422
        return $this;
423
    }
424
425
    /**
426
     * Get archivedPeriod
427
     *
428
     * @return HistoricPeriod
429
     */
430
    public function getArchivedPeriod()
431
    {
432
        return $this->archivedPeriod;
433
    }
434
435
    /**
436
     * @return Version
437
     */
438
    public function getCurrentVersion()
439
    {
440
        return $this->currentVersion;
441
    }
442
443
    /**
444
     * @param Version $currentVersion
445
     * @return Entry
446
     */
447
    public function setCurrentVersion($currentVersion = null)
448
    {
449
        $this->currentVersion = $currentVersion;
450
        return $this;
451
    }
452
453
    /**
454
     * Get public
455
     *
456
     * @return bool
457
     */
458
    public function isPublic()
459
    {
460
        return $this->public;
461
    }
462
463
    /**
464
     * Set public
465
     *
466
     * @param bool $public
467
     *
468
     * @return Entry
469
     */
470
    public function setPublic($public)
471
    {
472
        $this->public = $public;
473
        return $this;
474
    }
475
476
    /**
477
     * Get publicToken
478
     *
479
     * @return string
480
     */
481
    public function getPublicToken()
482
    {
483
        return $this->publicToken;
484
    }
485
486
    /**
487
     * Set publicToken
488
     *
489
     * @param string $publicToken
490
     *
491
     * @return Entry
492
     */
493
    public function setPublicToken($publicToken)
494
    {
495
        $this->publicToken = $publicToken;
496
        return $this;
497
    }
498
499
    /**
500
     * Set state
501
     *
502
     * @param integer $state
503
     *
504
     * @return Entry
505
     */
506
    public function setState($state)
507
    {
508
        $this->state = $state;
509
510
        return $this;
511
    }
512
513
    /**
514
     * Get state
515
     *
516
     * @return integer
517
     */
518
    public function getState()
519
    {
520
        return $this->state;
521
    }
522
523
    /**
524
     * Set stateChangedAt
525
     *
526
     * @param \DateTime $stateChangedAt
527
     *
528
     * @return Entry
529
     */
530
    public function setStateChangedAt($stateChangedAt)
531
    {
532
        $this->stateChangedAt = $stateChangedAt;
533
534
        return $this;
535
    }
536
537
    /**
538
     * Get stateChangedAt
539
     *
540
     * @return \DateTime
541
     */
542
    public function getStateChangedAt()
543
    {
544
        return $this->stateChangedAt;
545
    }
546
}
547