1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace App\Guests\Entity; |
5
|
|
|
|
6
|
|
|
use App\Movies\Entity\Movie; |
7
|
|
|
use App\Movies\Entity\WatchedMovie; |
8
|
|
|
use App\Users\Entity\User; |
9
|
|
|
use Doctrine\ORM\Mapping as ORM; |
10
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
11
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
12
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @ORM\Entity(repositoryClass="App\Guests\Repository\WatchedMovieRepository") |
16
|
|
|
* @ORM\Table(name="guests_watched_movies", |
17
|
|
|
* uniqueConstraints={ |
18
|
|
|
* @ORM\UniqueConstraint(name="idx_GuestWatchedMovie_guest_session_id_movie_id", columns={"guest_session_id", "movie_id"}) |
19
|
|
|
* }) |
20
|
|
|
*/ |
21
|
|
|
class GuestWatchedMovie extends WatchedMovie |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @ORM\Id() |
25
|
|
|
* @ORM\GeneratedValue() |
26
|
|
|
* @ORM\Column(type="integer") |
27
|
|
|
* @Groups({"list"}) |
28
|
|
|
*/ |
29
|
|
|
private $id; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @ORM\ManyToOne(targetEntity="App\Guests\Entity\GuestSession") |
33
|
|
|
* @ORM\JoinColumn(nullable=false) |
34
|
|
|
*/ |
35
|
|
|
private $guestSession; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* UserWatchedMovies constructor. |
39
|
|
|
* @param GuestSession $guestSession |
40
|
|
|
* @param Movie $movie |
41
|
|
|
* @param float|null $vote |
42
|
|
|
* @param \DateTimeInterface|null $watchedAt |
43
|
|
|
* @throws \Exception |
44
|
|
|
*/ |
45
|
3 |
|
public function __construct(GuestSession $guestSession, Movie $movie, ?float $vote, ?\DateTimeInterface $watchedAt) |
46
|
|
|
{ |
47
|
3 |
|
$this->guestSession = $guestSession; |
48
|
3 |
|
parent::__construct($movie, $vote, $watchedAt); |
49
|
3 |
|
} |
50
|
|
|
|
51
|
|
|
public function setGuestSession(GuestSession $guestSession): void |
52
|
|
|
{ |
53
|
|
|
$this->guestSession = $guestSession; |
54
|
|
|
} |
55
|
|
|
|
56
|
1 |
|
public function getGuestSession(): ?GuestSession |
57
|
|
|
{ |
58
|
1 |
|
return $this->guestSession; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function getId(): int |
62
|
|
|
{ |
63
|
|
|
return (int)$this->id; |
64
|
|
|
} |
65
|
|
|
} |