CBlogTask::getTaskId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CourseBundle\Entity;
8
9
use ApiPlatform\Metadata\ApiResource;
10
use ApiPlatform\Metadata\Delete;
11
use ApiPlatform\Metadata\Get;
12
use ApiPlatform\Metadata\GetCollection;
13
use ApiPlatform\Metadata\Patch;
14
use ApiPlatform\Metadata\Post;
15
use Chamilo\CoreBundle\Entity\User;
16
use Chamilo\CoreBundle\State\CBlogAssignAuthorProcessor;
17
use Doctrine\ORM\Mapping as ORM;
18
use Symfony\Component\Serializer\Annotation\Groups;
19
20
#[ORM\Table(name: 'c_blog_task')]
21
#[ORM\Entity]
22
#[ApiResource(
23
    operations: [
24
        new Get(),
25
        new GetCollection(),
26
        new Post(
27
            security: "is_granted('ROLE_USER')",
28
            processor: CBlogAssignAuthorProcessor::class
29
        ),
30
        new Patch(security: "object.getAuthor() === user or is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_TEACHER') or is_granted('ROLE_ADMIN')"),
31
        new Delete(security: "object.getAuthor() === user or is_granted('ROLE_CURRENT_COURSE_TEACHER') or is_granted('ROLE_TEACHER') or is_granted('ROLE_ADMIN')"),
32
    ],
33
    normalizationContext: ['groups' => ['blog_task:read']],
34
    denormalizationContext: ['groups' => ['blog_task:write']]
35
)]
36
class CBlogTask
37
{
38
    #[ORM\Column(name: 'iid', type: 'integer')]
39
    #[ORM\Id]
40
    #[ORM\GeneratedValue]
41
    #[Groups(['blog_task:read', 'task_rel_user:read'])]
42
    protected ?int $iid = null;
43
44
    #[ORM\Column(name: 'task_id', type: 'integer', nullable: false, options: ['default' => 0])]
45
    #[Groups(['blog_task:read', 'blog_task:write', 'task_rel_user:read'])]
46
    protected int $taskId = 0;
47
48
    #[ORM\Column(name: 'title', type: 'string', length: 250, nullable: false)]
49
    #[Groups(['blog_task:read', 'blog_task:write', 'task_rel_user:read'])]
50
    protected string $title;
51
52
    #[ORM\Column(name: 'description', type: 'text', nullable: true)]
53
    #[Groups(['blog_task:read', 'blog_task:write'])]
54
    protected string $description = '';
55
56
    #[ORM\Column(name: 'color', type: 'string', length: 10, nullable: false, options: ['default' => '#0ea5e9'])]
57
    #[Groups(['blog_task:read', 'blog_task:write'])]
58
    protected string $color = '#0ea5e9';
59
60
    #[ORM\Column(name: 'system_task', type: 'boolean', nullable: false, options: ['default' => false])]
61
    #[Groups(['blog_task:read', 'blog_task:write'])]
62
    protected bool $systemTask = false;
63
64
    #[ORM\ManyToOne(targetEntity: CBlog::class)]
65
    #[ORM\JoinColumn(name: 'blog_id', referencedColumnName: 'iid', nullable: false, onDelete: 'CASCADE')]
66
    #[Groups(['blog_task:read', 'blog_task:write'])]
67
    protected ?CBlog $blog = null;
68
69
    #[ORM\ManyToOne(targetEntity: User::class)]
70
    #[ORM\JoinColumn(name: 'author_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
71
    #[Groups(['blog_task:read'])]
72
    protected ?User $author = null;
73
74
    public function getIid(): ?int
75
    {
76
        return $this->iid;
77
    }
78
79
    public function getTaskId(): int
80
    {
81
        return $this->taskId;
82
    }
83
84
    public function setTaskId(int $taskId): self
85
    {
86
        $this->taskId = $taskId;
87
88
        return $this;
89
    }
90
91
    public function getTitle(): string
92
    {
93
        return $this->title;
94
    }
95
96
    public function setTitle(string $title): self
97
    {
98
        $this->title = $title;
99
100
        return $this;
101
    }
102
103
    public function getDescription(): string
104
    {
105
        return $this->description ?? '';
106
    }
107
108
    public function setDescription(string $description): self
109
    {
110
        $this->description = $description;
111
112
        return $this;
113
    }
114
115
    public function getColor(): string
116
    {
117
        return $this->color;
118
    }
119
120
    public function setColor(string $color): self
121
    {
122
        $this->color = $color;
123
124
        return $this;
125
    }
126
127
    public function isSystemTask(): bool
128
    {
129
        return $this->systemTask;
130
    }
131
132
    public function setSystemTask(bool $systemTask): self
133
    {
134
        $this->systemTask = $systemTask;
135
136
        return $this;
137
    }
138
139
    public function getBlog(): ?CBlog
140
    {
141
        return $this->blog;
142
    }
143
144
    public function setBlog(?CBlog $blog): self
145
    {
146
        $this->blog = $blog;
147
148
        return $this;
149
    }
150
151
    public function getAuthor(): ?User
152
    {
153
        return $this->author;
154
    }
155
156
    public function setAuthor(?User $author): self
157
    {
158
        $this->author = $author;
159
160
        return $this;
161
    }
162
163
    #[Groups(['blog_task:read'])]
164
    public function getAuthorId(): ?int
165
    {
166
        return method_exists($this->author, 'getId') ? $this->author->getId() : null;
0 ignored issues
show
Bug introduced by
The method getId() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

166
        return method_exists($this->author, 'getId') ? $this->author->/** @scrutinizer ignore-call */ getId() : null;

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
167
    }
168
}
169