Passed
Push — master ( 719760...59ab2e )
by Angel Fernando Quiroz
18:35
created

CStudentPublicationAssignment::setAddToCalendar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
declare(strict_types=1);
6
7
namespace Chamilo\CourseBundle\Entity;
8
9
use ApiPlatform\Action\NotFoundAction;
10
use ApiPlatform\Metadata\ApiResource;
11
use ApiPlatform\Metadata\Get;
12
use Chamilo\CourseBundle\Repository\CStudentPublicationAssignmentRepository;
13
use DateTime;
14
use Doctrine\ORM\Mapping as ORM;
15
use Stringable;
16
use Symfony\Component\Serializer\Annotation\Groups;
17
use Symfony\Component\Validator\Constraints as Assert;
18
19
#[ORM\Table(name: 'c_student_publication_assignment')]
20
#[ORM\Entity(repositoryClass: CStudentPublicationAssignmentRepository::class)]
21
#[ApiResource(
22
    operations: [
23
        new Get(
24
            controller: NotFoundAction::class,
25
            output: false,
26
            read: false,
27
        ),
28
    ],
29
)]
30
class CStudentPublicationAssignment implements Stringable
31
{
32
    #[ORM\Column(name: 'iid', type: 'integer')]
33
    #[ORM\Id]
34
    #[ORM\GeneratedValue]
35
    protected ?int $iid = null;
36
37
    #[ORM\Column(name: 'expires_on', type: 'datetime', nullable: true)]
38
    #[Groups(['c_student_publication:write', 'student_publication:read'])]
39
    protected ?DateTime $expiresOn = null;
40
41
    #[ORM\Column(name: 'ends_on', type: 'datetime', nullable: true)]
42
    #[Groups(['c_student_publication:write', 'student_publication:read'])]
43
    #[Assert\GreaterThanOrEqual(propertyPath: 'expiresOn')]
44
    protected ?DateTime $endsOn = null;
45
46
    #[ORM\Column(name: 'add_to_calendar', type: 'integer', nullable: false)]
47
    #[Groups(['student_publication:item:get'])]
48
    protected int $eventCalendarId = 0;
49
50
    #[ORM\Column(name: 'enable_qualification', type: 'boolean', nullable: false)]
51
    protected bool $enableQualification;
52
53
    #[ORM\OneToOne(inversedBy: 'assignment', targetEntity: CStudentPublication::class)]
54
    #[ORM\JoinColumn(name: 'publication_id', referencedColumnName: 'iid', onDelete: 'CASCADE')]
55
    protected CStudentPublication $publication;
56
57
    public function __toString(): string
58
    {
59
        return (string) $this->getIid();
60
    }
61
62
    public function getIid(): ?int
63
    {
64
        return $this->iid;
65
    }
66
67
    public function getExpiresOn(): ?DateTime
68
    {
69
        return $this->expiresOn;
70
    }
71
72
    public function setExpiresOn(?DateTime $expiresOn): self
73
    {
74
        $this->expiresOn = $expiresOn;
75
76
        return $this;
77
    }
78
79
    public function getEndsOn(): ?DateTime
80
    {
81
        return $this->endsOn;
82
    }
83
84
    public function setEndsOn(?DateTime $endsOn): self
85
    {
86
        $this->endsOn = $endsOn;
87
88
        return $this;
89
    }
90
91
    public function getEventCalendarId(): int
92
    {
93
        return $this->eventCalendarId;
94
    }
95
96
    public function setEventCalendarId(int $eventCalendarId): self
97
    {
98
        $this->eventCalendarId = $eventCalendarId;
99
100
        return $this;
101
    }
102
103
    public function getEnableQualification(): bool
104
    {
105
        return $this->enableQualification;
106
    }
107
108
    public function setEnableQualification(bool $enableQualification): self
109
    {
110
        $this->enableQualification = $enableQualification;
111
112
        return $this;
113
    }
114
115
    public function getPublication(): CStudentPublication
116
    {
117
        return $this->publication;
118
    }
119
120
    public function setPublication(CStudentPublication $publication): self
121
    {
122
        $this->publication = $publication;
123
124
        $qualification = $this->publication->getQualification();
125
126
        $this->enableQualification = !empty($qualification);
127
128
        return $this;
129
    }
130
131
    /*
132
    public function getResourceIdentifier(): int
133
    {
134
        return $this->getIid();
135
    }
136
137
    public function getResourceName(): string
138
    {
139
        return (string) $this->getIid();
140
    }
141
142
    public function setResourceName(string $name): self
143
    {
144
        //return $this->setTitle($name);
145
    }*/
146
}
147