Completed
Push — master ( a34f18...c6c5e0 )
by Julito
15:01
created

CTool::getSession()   A

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
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CourseBundle\Entity;
5
6
use Chamilo\CoreBundle\Entity\Course;
7
use Chamilo\CoreBundle\Entity\Session;
8
use Chamilo\CoreBundle\Entity\Tool;
9
use Doctrine\ORM\Event\LifecycleEventArgs;
10
use Doctrine\ORM\Mapping as ORM;
11
12
/**
13
 * CTool.
14
 *
15
 * @ORM\HasLifecycleCallbacks
16
 * @ORM\Table(
17
 *  name="c_tool",
18
 *  indexes={
19
 *      @ORM\Index(name="course", columns={"c_id"}),
20
 *      @ORM\Index(name="session_id", columns={"session_id"})
21
 *  }
22
 * )
23
 * @ORM\Entity
24
 */
25
class CTool
26
{
27
    /**
28
     * @var int
29
     *
30
     * @ORM\Column(name="iid", type="integer")
31
     * @ORM\Id
32
     * @ORM\GeneratedValue
33
     */
34
    protected $iid;
35
36
    /**
37
     * @var int
38
     *
39
     * @ORM\Column(name="id", type="integer", nullable=true)
40
     */
41
    protected $id;
42
43
    /**
44
     * @var bool
45
     *
46
     * @ORM\Column(name="visibility", type="boolean", nullable=true)
47
     */
48
    protected $visibility;
49
50
    /**
51
     * @var string
52
     *
53
     * @ORM\Column(name="category", type="string", length=20, nullable=false, options={"default" = "authoring"})
54
     */
55
    protected $category;
56
57
    /**
58
     * @var string
59
     *
60
     * @ORM\Column(name="custom_icon", type="string", length=255, nullable=true)
61
     */
62
    protected $customIcon;
63
64
    /**
65
     * @var Course
66
     *
67
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="tools")
68
     * @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false)
69
     */
70
    protected $course;
71
72
    /**
73
     * @var Session
74
     *
75
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session")
76
     * @ORM\JoinColumn(name="session_id", referencedColumnName="id", nullable=true)
77
     */
78
    protected $session;
79
80
    /**
81
     * @var Tool
82
     *
83
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Tool")
84
     * @ORM\JoinColumn(name="tool_id", referencedColumnName="id", nullable=false)
85
     */
86
    protected $tool;
87
88
    /**
89
     * Constructor.
90
     */
91
    public function __construct()
92
    {
93
        // Default values
94
        $this->id = 0;
95
    }
96
97
    /**
98
     * @return int
99
     */
100
    public function getIid()
101
    {
102
        return $this->iid;
103
    }
104
105
    /**
106
     * @param int $iid
107
     *
108
     * @return CTool
109
     */
110
    public function setIid($iid)
111
    {
112
        $this->iid = $iid;
113
114
        return $this;
115
    }
116
117
    /**
118
     * @return $this
119
     */
120
    public function setCourse(Course $course)
121
    {
122
        $this->course = $course;
123
124
        return $this;
125
    }
126
127
    public function getCourse(): Course
128
    {
129
        return $this->course;
130
    }
131
132
    /**
133
     * @return Session
134
     */
135
    public function getSession(): ?Session
136
    {
137
        return $this->session;
138
    }
139
140
    /**
141
     * @param Session $session
142
     *
143
     * @return CTool
144
     */
145
    public function setSession(Session $session = null): CTool
146
    {
147
        $this->session = $session;
148
149
        return $this;
150
    }
151
152
    public static function loadValidatorMetadata(ClassMetadata $metadata)
0 ignored issues
show
Unused Code introduced by
The parameter $metadata is not used and could be removed. ( Ignorable by Annotation )

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

152
    public static function loadValidatorMetadata(/** @scrutinizer ignore-unused */ ClassMetadata $metadata)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
153
    {
154
        /*$metadata->addPropertyConstraint(
155
            'customIcon',
156
            new Assert\File(['mimeTypes' => ['image/png']])
157
        );
158
        $metadata->addPropertyConstraint(
159
            'customIcon',
160
            new Assert\Image(['maxWidth' => 64, 'minHeight' => 64])
161
        );
162
        $metadata->addPropertyConstraint('cId', new Assert\NotBlank());*/
163
    }
164
165
    /**
166
     * Set visibility.
167
     *
168
     * @param bool $visibility
169
     *
170
     * @return CTool
171
     */
172
    public function setVisibility($visibility)
173
    {
174
        $this->visibility = $visibility;
175
176
        return $this;
177
    }
178
179
    /**
180
     * Get visibility.
181
     *
182
     * @return bool
183
     */
184
    public function getVisibility()
185
    {
186
        return $this->visibility;
187
    }
188
189
    /**
190
     * Set category.
191
     *
192
     * @param string $category
193
     *
194
     * @return CTool
195
     */
196
    public function setCategory($category)
197
    {
198
        $this->category = $category;
199
200
        return $this;
201
    }
202
203
    /**
204
     * Get category.
205
     *
206
     * @return string
207
     */
208
    public function getCategory()
209
    {
210
        return $this->category;
211
    }
212
213
    /**
214
     * Set id.
215
     *
216
     * @param int $id
217
     *
218
     * @return CTool
219
     */
220
    public function setId($id)
221
    {
222
        $this->id = $id;
223
224
        return $this;
225
    }
226
227
    /**
228
     * Get id.
229
     *
230
     * @return int
231
     */
232
    public function getId()
233
    {
234
        return $this->id;
235
    }
236
237
    /**
238
     * @return string
239
     */
240
    public function getCustomIcon()
241
    {
242
        return $this->customIcon;
243
    }
244
245
    /**
246
     * @param string $customIcon
247
     *
248
     * @return CTool
249
     */
250
    public function setCustomIcon($customIcon)
251
    {
252
        $this->customIcon = $customIcon;
253
254
        return $this;
255
    }
256
257
    /**
258
     * @return Tool
259
     */
260
    public function getTool(): Tool
261
    {
262
        return $this->tool;
263
    }
264
265
    /**
266
     * @param Tool $tool
267
     *
268
     * @return CTool
269
     */
270
    public function setTool(Tool $tool): CTool
271
    {
272
        $this->tool = $tool;
273
274
        return $this;
275
    }
276
277
    /**
278
     * @ORM\PostPersist()
279
     */
280
    public function postPersist(LifecycleEventArgs $args)
281
    {
282
        // Update id with iid value
283
        $em = $args->getEntityManager();
284
        $this->setId($this->iid);
285
        $em->persist($this);
286
        $em->flush($this);
287
    }
288
}
289