Passed
Push — master ( 698027...ac354c )
by Julito
12:13
created

CDocument::setSession()   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
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CourseBundle\Entity;
5
6
use Chamilo\CoreBundle\Entity\Course;
7
use Chamilo\CoreBundle\Entity\Resource\AbstractResource;
8
use Chamilo\CoreBundle\Entity\Resource\ResourceInterface;
9
use Chamilo\CoreBundle\Entity\Session;
10
use Doctrine\ORM\Mapping as ORM;
11
use APY\DataGridBundle\Grid\Mapping as GRID;
12
use Doctrine\ORM\Event\LifecycleEventArgs;
13
14
/**
15
 * CDocument.
16
 *
17
 * @ORM\Table(
18
 *  name="c_document",
19
 *  indexes={
20
 *      @ORM\Index(name="course", columns={"c_id"})
21
 *  }
22
 * )
23
 * @GRID\Source(columns="iid, id, title, filetype", filterable=false)
24
 *
25
 * @ORM\Entity(repositoryClass="Chamilo\CourseBundle\Repository\CDocumentRepository")
26
 */
27
class CDocument extends AbstractResource implements ResourceInterface
28
{
29
    /**
30
     * @var int
31
     *
32
     * @ORM\Column(name="iid", type="integer")
33
     * @ORM\Id
34
     * @ORM\GeneratedValue
35
     */
36
    protected $iid;
37
38
    /**
39
     * @var int
40
     *
41
     * @ORM\Column(name="id", type="integer", nullable=true)
42
     */
43
    protected $id;
44
45
    /**
46
     * @var string
47
     *
48
     * @ORM\Column(name="path", type="string", length=255, nullable=false)
49
     */
50
    protected $path;
51
52
    /**
53
     * @var string
54
     *
55
     * @ORM\Column(name="comment", type="text", nullable=true)
56
     */
57
    protected $comment;
58
59
    /**
60
     * @var string
61
     *
62
     * @ORM\Column(name="title", type="string", length=255, nullable=true)
63
     */
64
    protected $title;
65
66
    /**
67
     * @var string
68
     *
69
     * @ORM\Column(name="filetype", type="string", length=10, nullable=false)
70
     */
71
    protected $filetype;
72
73
    /**
74
     * @var int
75
     *
76
     * @ORM\Column(name="size", type="integer", nullable=false)
77
     */
78
    protected $size;
79
80
    /**
81
     * @var bool
82
     *
83
     * @ORM\Column(name="readonly", type="boolean", nullable=false)
84
     */
85
    protected $readonly;
86
87
    /**
88
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", cascade={"persist"})
89
     * @ORM\JoinColumn(name="c_id", referencedColumnName="id")
90
     */
91
    protected $course;
92
93
    /**
94
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session", cascade={"persist"})
95
     * @ORM\JoinColumn(name="session_id", referencedColumnName="id")
96
     */
97
    protected $session;
98
99
    /**
100
     * CDocument constructor.
101
     */
102
    public function __construct()
103
    {
104
    }
105
106
    /**
107
     * Set path.
108
     *
109
     * @param string $path
110
     *
111
     * @return CDocument
112
     */
113
    public function setPath($path)
114
    {
115
        $this->path = $path;
116
117
        return $this;
118
    }
119
120
    /**
121
     * Get path.
122
     *
123
     * @return string
124
     */
125
    public function getPath()
126
    {
127
        return $this->path;
128
    }
129
130
    /**
131
     * Set comment.
132
     *
133
     * @param string $comment
134
     *
135
     * @return CDocument
136
     */
137
    public function setComment($comment)
138
    {
139
        $this->comment = $comment;
140
141
        return $this;
142
    }
143
144
    /**
145
     * Get comment.
146
     *
147
     * @return string
148
     */
149
    public function getComment()
150
    {
151
        return $this->comment;
152
    }
153
154
    /**
155
     * Set title.
156
     *
157
     * @param string $title
158
     *
159
     * @return CDocument
160
     */
161
    public function setTitle($title)
162
    {
163
        $this->title = $title;
164
165
        return $this;
166
    }
167
168
    /**
169
     * Get title.
170
     *
171
     * @return string
172
     */
173
    public function getTitle()
174
    {
175
        return $this->title;
176
    }
177
178
    /**
179
     * Set filetype.
180
     *
181
     * @param string $filetype
182
     *
183
     * @return CDocument
184
     */
185
    public function setFiletype($filetype)
186
    {
187
        $this->filetype = $filetype;
188
189
        return $this;
190
    }
191
192
    /**
193
     * Get filetype.
194
     *
195
     * @return string
196
     */
197
    public function getFiletype()
198
    {
199
        return $this->filetype;
200
    }
201
202
    /**
203
     * Set size.
204
     *
205
     * @param int $size
206
     *
207
     * @return CDocument
208
     */
209
    public function setSize($size)
210
    {
211
        $this->size = $size;
212
213
        return $this;
214
    }
215
216
    /**
217
     * Get size.
218
     *
219
     * @return int
220
     */
221
    public function getSize()
222
    {
223
        return $this->size;
224
    }
225
226
    /**
227
     * Set readonly.
228
     *
229
     * @param bool $readonly
230
     *
231
     * @return CDocument
232
     */
233
    public function setReadonly($readonly)
234
    {
235
        $this->readonly = $readonly;
236
237
        return $this;
238
    }
239
240
    /**
241
     * Get readonly.
242
     *
243
     * @return bool
244
     */
245
    public function getReadonly()
246
    {
247
        return $this->readonly;
248
    }
249
250
    /**
251
     * Set id.
252
     *
253
     * @param int $id
254
     *
255
     * @return CDocument
256
     */
257
    public function setId($id)
258
    {
259
        $this->id = $id;
260
261
        return $this;
262
    }
263
264
    /**
265
     * Get id.
266
     *
267
     * @return int
268
     */
269
    public function getId()
270
    {
271
        return $this->id;
272
    }
273
274
    /**
275
     * @return Course
276
     */
277
    public function getCourse(): Course
278
    {
279
        return $this->course;
280
    }
281
282
    /**
283
     * @param Course $course
284
     *
285
     * @return CDocument
286
     */
287
    public function setCourse($course)
288
    {
289
        $this->course = $course;
290
291
        return $this;
292
    }
293
294
    /**
295
     * @return int
296
     */
297
    public function getIid()
298
    {
299
        return $this->iid;
300
    }
301
302
    /**
303
     * @return Session
304
     */
305
    public function getSession()
306
    {
307
        return $this->session;
308
    }
309
310
    /**
311
     * @param Session $session
312
     *
313
     * @return CDocument
314
     */
315
    public function setSession($session)
316
    {
317
        $this->session = $session;
318
319
        return $this;
320
    }
321
322
    /**
323
     * @ORM\PostPersist()
324
     *
325
     * @param LifecycleEventArgs $args
326
     *
327
     */
328
    public function postPersist(LifecycleEventArgs $args)
329
    {
330
        // Update id with iid value
331
        $em = $args->getEntityManager();
332
        $this->setId($this->iid);
333
        $em->persist($this);
334
        $em->flush($this);
335
    }
336
337
    // Resource classes
338
339
    public function getResourceIdentifier(): int
340
    {
341
        return $this->getIid();
342
    }
343
344
    public function getResourceName(): string
345
    {
346
        return $this->getTitle();
347
    }
348
349
    public function getToolName(): string
350
    {
351
        return 'document';
352
    }
353
354
    public function __get($a) {
355
356
    }
357
}
358