|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Knp\DoctrineBehaviors\Model as ORMBehaviors; |
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
8
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
9
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Survey. |
|
13
|
|
|
* |
|
14
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\SurveyRepository") |
|
15
|
|
|
*/ |
|
16
|
|
|
class Survey |
|
17
|
|
|
{ |
|
18
|
|
|
use ORMBehaviors\Timestampable\Timestampable; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var int |
|
22
|
|
|
* |
|
23
|
|
|
* @ORM\Column(type="integer") |
|
24
|
|
|
* @ORM\Id |
|
25
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
26
|
|
|
* @Groups({"group1"}) |
|
27
|
|
|
*/ |
|
28
|
|
|
private $id; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var SurveyType |
|
32
|
|
|
* @Assert\Type("object") |
|
33
|
|
|
* @Assert\Valid |
|
34
|
|
|
* @ORM\ManyToOne(targetEntity="SurveyType", inversedBy="surveys") |
|
35
|
|
|
* @Groups({"group1"}) |
|
36
|
|
|
*/ |
|
37
|
|
|
private $type; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string |
|
41
|
|
|
* @Assert\NotBlank() |
|
42
|
|
|
* @Assert\Type("string") |
|
43
|
|
|
* @ORM\Column(type="string") |
|
44
|
|
|
* @Groups({"group1"}) |
|
45
|
|
|
*/ |
|
46
|
|
|
private $status = 'current'; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var User |
|
50
|
|
|
* @Assert\Type("object") |
|
51
|
|
|
* @Assert\Valid |
|
52
|
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="surveys") |
|
53
|
|
|
*/ |
|
54
|
|
|
private $user; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var ArrayCollection[SurveyAnswer] |
|
58
|
|
|
* @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="survey", cascade={"persist", "remove"}) |
|
59
|
|
|
*/ |
|
60
|
|
|
private $answers; |
|
61
|
|
|
|
|
62
|
1 |
|
public function __construct() |
|
63
|
|
|
{ |
|
64
|
1 |
|
$this->answers = new ArrayCollection(); |
|
65
|
1 |
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Get id. |
|
69
|
|
|
* |
|
70
|
|
|
* @return int |
|
71
|
|
|
*/ |
|
72
|
3 |
|
public function getId() |
|
73
|
|
|
{ |
|
74
|
3 |
|
return $this->id; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Set type. |
|
79
|
|
|
* |
|
80
|
|
|
* @param SurveyType $type |
|
81
|
|
|
* |
|
82
|
|
|
* @return Survey |
|
83
|
|
|
*/ |
|
84
|
1 |
|
public function setType(SurveyType $type) |
|
85
|
|
|
{ |
|
86
|
1 |
|
$this->type = $type; |
|
87
|
|
|
|
|
88
|
1 |
|
return $this; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Get type. |
|
93
|
|
|
* |
|
94
|
|
|
* @return SurveyType |
|
95
|
|
|
*/ |
|
96
|
7 |
|
public function getType() |
|
97
|
|
|
{ |
|
98
|
7 |
|
return $this->type; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Set status. |
|
103
|
|
|
* |
|
104
|
|
|
* @param string $status |
|
105
|
|
|
* |
|
106
|
|
|
* @return Survey |
|
107
|
|
|
*/ |
|
108
|
1 |
|
public function setStatus($status) |
|
109
|
|
|
{ |
|
110
|
1 |
|
$this->status = $status; |
|
111
|
|
|
|
|
112
|
1 |
|
return $this; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Get status. |
|
117
|
|
|
* |
|
118
|
|
|
* @return string |
|
119
|
|
|
*/ |
|
120
|
3 |
|
public function getStatus() |
|
121
|
|
|
{ |
|
122
|
3 |
|
return $this->status; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* Set user. |
|
127
|
|
|
* |
|
128
|
|
|
* @param User $user |
|
129
|
|
|
* |
|
130
|
|
|
* @return Survey |
|
131
|
|
|
*/ |
|
132
|
1 |
|
public function setUser(User $user) |
|
133
|
|
|
{ |
|
134
|
1 |
|
$this->user = $user; |
|
135
|
|
|
|
|
136
|
1 |
|
return $this; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Get user. |
|
141
|
|
|
* |
|
142
|
|
|
* @return User |
|
143
|
|
|
*/ |
|
144
|
4 |
|
public function getUser() |
|
145
|
|
|
{ |
|
146
|
4 |
|
return $this->user; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Get answers. |
|
151
|
|
|
* |
|
152
|
|
|
* @return ArrayCollection |
|
153
|
|
|
*/ |
|
154
|
|
|
public function getAnswers() |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->answers; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* Get DateTime. |
|
161
|
|
|
* |
|
162
|
|
|
* @return \DateTime |
|
163
|
|
|
* @Groups({"group1", "group2"}) |
|
164
|
|
|
*/ |
|
165
|
2 |
|
public function getCreatedAt() |
|
166
|
|
|
{ |
|
167
|
2 |
|
return $this->createdAt; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* Get DateTime. |
|
172
|
|
|
* |
|
173
|
|
|
* @return \DateTime |
|
174
|
|
|
* @Groups({"group1", "group2"}) |
|
175
|
|
|
*/ |
|
176
|
3 |
|
public function getUpdatedAt() |
|
177
|
|
|
{ |
|
178
|
3 |
|
return $this->updatedAt; |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
|