Completed
Push — master ( 38e61c...cd9a17 )
by Julito
14:03
created

CQuizQuestionCategory::setDescription()   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\Resource\AbstractResource;
7
use Chamilo\CoreBundle\Entity\Resource\ResourceInterface;
8
use Doctrine\ORM\Event\LifecycleEventArgs;
9
use Doctrine\ORM\Mapping as ORM;
10
11
/**
12
 * CQuizQuestionCategory.
13
 *
14
 * @ORM\Table(
15
 *  name="c_quiz_question_category",
16
 *  indexes={
17
 *      @ORM\Index(name="course", columns={"c_id"})
18
 *  }
19
 * )
20
 * @ORM\Entity
21
 */
22
class CQuizQuestionCategory extends AbstractResource implements ResourceInterface
23
{
24
    /**
25
     * @var int
26
     *
27
     * @ORM\Column(name="iid", type="integer")
28
     * @ORM\Id
29
     * @ORM\GeneratedValue
30
     */
31
    protected $iid;
32
33
    /**
34
     * @var int
35
     *
36
     * @ORM\Column(name="c_id", type="integer")
37
     */
38
    protected $cId;
39
40
    /**
41
     * @var int
42
     *
43
     * @ORM\Column(name="id", type="integer", nullable=true)
44
     */
45
    protected $id;
46
47
    /**
48
     * @var string
49
     *
50
     * @ORM\Column(name="title", type="string", length=255, nullable=false)
51
     */
52
    protected $title;
53
54
    /**
55
     * @var string
56
     *
57
     * @ORM\Column(name="description", type="text", nullable=true)
58
     */
59
    protected $description;
60
61
    /**
62
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session", cascade={"persist"})
63
     * @ORM\JoinColumn(name="session_id", referencedColumnName="id", nullable=true)
64
     */
65
    protected $session;
66
67
    /**
68
     * @return int
69
     */
70
    public function getIid()
71
    {
72
        return $this->iid;
73
    }
74
75
    /**
76
     * Set title.
77
     *
78
     * @param string $title
79
     *
80
     * @return CQuizQuestionCategory
81
     */
82
    public function setTitle($title)
83
    {
84
        $this->title = $title;
85
86
        return $this;
87
    }
88
89
    /**
90
     * Get title.
91
     *
92
     * @return string
93
     */
94
    public function getTitle()
95
    {
96
        return $this->title;
97
    }
98
99
    /**
100
     * Set description.
101
     *
102
     * @param string $description
103
     *
104
     * @return CQuizQuestionCategory
105
     */
106
    public function setDescription($description)
107
    {
108
        $this->description = $description;
109
110
        return $this;
111
    }
112
113
    /**
114
     * Get description.
115
     *
116
     * @return string
117
     */
118
    public function getDescription()
119
    {
120
        return $this->description;
121
    }
122
123
    /**
124
     * Set id.
125
     *
126
     * @param int $id
127
     *
128
     * @return CQuizQuestionCategory
129
     */
130
    public function setId($id)
131
    {
132
        $this->id = $id;
133
134
        return $this;
135
    }
136
137
    /**
138
     * Get id.
139
     *
140
     * @return int
141
     */
142
    public function getId()
143
    {
144
        return $this->id;
145
    }
146
147
    /**
148
     * Set cId.
149
     *
150
     * @param int $cId
151
     *
152
     * @return CQuizQuestionCategory
153
     */
154
    public function setCId($cId)
155
    {
156
        $this->cId = $cId;
157
158
        return $this;
159
    }
160
161
    /**
162
     * Get cId.
163
     *
164
     * @return int
165
     */
166
    public function getCId()
167
    {
168
        return $this->cId;
169
    }
170
171
    /**
172
     * @ORM\PostPersist()
173
     *
174
     * @param LifecycleEventArgs $args
175
     */
176
    public function postPersist(LifecycleEventArgs $args)
177
    {
178
        // Update id with iid value
179
        $em = $args->getEntityManager();
180
        $this->setId($this->iid);
181
        $em->persist($this);
182
        $em->flush();
183
    }
184
185
    /**
186
     * Resource identifier.
187
     *
188
     * @return int
189
     */
190
    public function getResourceIdentifier(): int
191
    {
192
        return $this->getIid();
193
    }
194
195
    /**
196
     * @return string
197
     */
198
    public function getResourceName(): string
199
    {
200
        return $this->getTitle();
201
    }
202
203
    /**
204
     * @return string
205
     */
206
    public function getToolName(): string
207
    {
208
        return 'exercise_category';
209
    }
210
}
211