1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* (c) Lukasz D. Tulikowski <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace App\Entity; |
13
|
|
|
|
14
|
|
|
use App\Traits\IdColumnTrait; |
15
|
|
|
use App\Traits\TimeAwareTrait; |
16
|
|
|
use Doctrine\ORM\Mapping as ORM; |
17
|
|
|
use JMS\Serializer\Annotation as JMS; |
18
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\ReviewRepository") |
22
|
|
|
* |
23
|
|
|
* @JMS\ExclusionPolicy("ALL") |
24
|
|
|
*/ |
25
|
|
|
class Review |
26
|
|
|
{ |
27
|
|
|
use IdColumnTrait; |
28
|
|
|
use TimeAwareTrait; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
* |
33
|
|
|
* @ORM\Column(type="text") |
34
|
|
|
* |
35
|
|
|
* @Assert\NotBlank |
36
|
|
|
* |
37
|
|
|
* @JMS\Expose |
38
|
|
|
*/ |
39
|
|
|
protected $body; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var int |
43
|
|
|
* |
44
|
|
|
* @ORM\Column(type="integer") |
45
|
|
|
* |
46
|
|
|
* @Assert\NotBlank |
47
|
|
|
* |
48
|
|
|
* @JMS\Expose |
49
|
|
|
*/ |
50
|
|
|
protected $rating; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var User |
54
|
|
|
* |
55
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="reviews", cascade={"persist", "remove"}) |
56
|
|
|
* |
57
|
|
|
* @JMS\Expose |
58
|
|
|
*/ |
59
|
|
|
protected $author; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var \DateTimeInterface |
63
|
|
|
* |
64
|
|
|
* @ORM\Column(type="date") |
65
|
|
|
* |
66
|
|
|
* @Assert\NotBlank |
67
|
|
|
* |
68
|
|
|
* @JMS\Expose |
69
|
|
|
*/ |
70
|
|
|
protected $publicationDate; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @var Book |
74
|
|
|
* |
75
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Book", inversedBy="reviews", cascade={"persist"}) |
76
|
|
|
* |
77
|
|
|
* @JMS\Groups({"books"}) |
78
|
|
|
*/ |
79
|
|
|
protected $book; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var Movie |
83
|
|
|
* |
84
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Movie", inversedBy="reviews", cascade={"persist"}) |
85
|
|
|
* |
86
|
|
|
* @JMS\Groups({"movies"}) |
87
|
|
|
*/ |
88
|
|
|
protected $movie; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return string|null |
92
|
|
|
*/ |
93
|
3 |
|
public function getBody(): ?string |
94
|
|
|
{ |
95
|
3 |
|
return $this->body; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param string $body |
100
|
|
|
* |
101
|
|
|
* @return Review |
102
|
|
|
*/ |
103
|
2 |
|
public function setBody(string $body): self |
104
|
|
|
{ |
105
|
2 |
|
$this->body = $body; |
106
|
|
|
|
107
|
2 |
|
return $this; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return int|null |
112
|
|
|
*/ |
113
|
3 |
|
public function getRating(): ?int |
114
|
|
|
{ |
115
|
3 |
|
return $this->rating; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param int $rating |
120
|
|
|
* |
121
|
|
|
* @return Review |
122
|
|
|
*/ |
123
|
3 |
|
public function setRating(int $rating): self |
124
|
|
|
{ |
125
|
3 |
|
$this->rating = $rating; |
126
|
|
|
|
127
|
3 |
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return \DateTimeInterface|null |
132
|
|
|
*/ |
133
|
3 |
|
public function getPublicationDate(): ?\DateTimeInterface |
134
|
|
|
{ |
135
|
3 |
|
return $this->publicationDate; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param \DateTimeInterface $publicationDate |
140
|
|
|
* |
141
|
|
|
* @return Review |
142
|
|
|
*/ |
143
|
2 |
|
public function setPublicationDate(?\DateTimeInterface $publicationDate): self |
144
|
|
|
{ |
145
|
2 |
|
$this->publicationDate = $publicationDate; |
146
|
|
|
|
147
|
2 |
|
return $this; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return User|null |
152
|
|
|
*/ |
153
|
3 |
|
public function getAuthor(): ?User |
154
|
|
|
{ |
155
|
3 |
|
return $this->author; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param User|null $author |
160
|
|
|
* |
161
|
|
|
* @return Review |
162
|
|
|
*/ |
163
|
2 |
|
public function setAuthor(?User $author): self |
164
|
|
|
{ |
165
|
2 |
|
$this->author = $author; |
166
|
|
|
|
167
|
2 |
|
return $this; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @return Book|null |
172
|
|
|
*/ |
173
|
|
|
public function getBook(): ?Book |
174
|
|
|
{ |
175
|
|
|
return $this->book; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @param Book|null $book |
180
|
|
|
* |
181
|
|
|
* @return Review |
182
|
|
|
*/ |
183
|
|
|
public function setBook(?Book $book): self |
184
|
|
|
{ |
185
|
|
|
$this->book = $book; |
186
|
|
|
|
187
|
|
|
return $this; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @return Movie|null |
192
|
|
|
*/ |
193
|
|
|
public function getMovie(): ?Movie |
194
|
|
|
{ |
195
|
|
|
return $this->movie; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @param Movie|null $movie |
200
|
|
|
* |
201
|
|
|
* @return Review |
202
|
|
|
*/ |
203
|
|
|
public function setMovie(?Movie $movie): self |
204
|
|
|
{ |
205
|
|
|
$this->movie = $movie; |
206
|
|
|
|
207
|
|
|
return $this; |
208
|
|
|
} |
209
|
|
|
} |
210
|
|
|
|