Completed
Push — master ( 4e608a...fcc2ac )
by
unknown
02:01 queued 37s
created

AttemptFile::clearResourceNode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
nc 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Entity;
8
9
use Doctrine\ORM\Mapping as ORM;
10
use Gedmo\Timestampable\Traits\TimestampableEntity;
11
use Symfony\Component\Uid\Uuid;
12
use Symfony\Component\Validator\Constraints as Assert;
13
14
#[ORM\Table(name: 'attempt_file')]
15
#[ORM\Entity]
16
class AttemptFile
17
{
18
    use TimestampableEntity;
19
20
    #[ORM\Id]
21
    #[ORM\Column(type: 'uuid')]
22
    protected Uuid $id;
23
24
    #[Assert\NotNull]
25
    #[ORM\ManyToOne(targetEntity: TrackEAttempt::class, inversedBy: 'attemptFiles')]
26
    #[ORM\JoinColumn(name: 'attempt_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
27
    protected TrackEAttempt $attempt;
28
29
    #[ORM\ManyToOne(targetEntity: ResourceNode::class)]
30
    protected ?ResourceNode $resourceNode = null;
31
32
    #[ORM\Column(name: 'comment', type: 'text', nullable: false)]
33
    protected string $comment;
34
35
    public function __construct()
36
    {
37
        $this->id = Uuid::v4();
38
        $this->comment = '';
39
    }
40
41
    public function getId(): Uuid
42
    {
43
        return $this->id;
44
    }
45
46
    public function getAttempt(): TrackEAttempt
47
    {
48
        return $this->attempt;
49
    }
50
51
    public function setAttempt(TrackEAttempt $attempt): self
52
    {
53
        $this->attempt = $attempt;
54
55
        return $this;
56
    }
57
58
    public function getResourceNode(): ?ResourceNode
59
    {
60
        return $this->resourceNode;
61
    }
62
63
    public function setResourceNode(?ResourceNode $resourceNode): self
64
    {
65
        $this->resourceNode = $resourceNode;
66
67
        return $this;
68
    }
69
70
    public function clearResourceNode(): self
71
    {
72
        // Detach the resource node reference when the file is removed.
73
        $this->resourceNode = null;
74
75
        return $this;
76
    }
77
78
    public function getComment(): string
79
    {
80
        return $this->comment;
81
    }
82
83
    public function setComment(string $comment): self
84
    {
85
        $this->comment = $comment;
86
87
        return $this;
88
    }
89
}
90