1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace App\Movies\Entity; |
5
|
|
|
|
6
|
|
|
use App\Movies\DTO\MovieTranslationDTO; |
7
|
|
|
use App\Translation\EntityTranslationInterface; |
8
|
|
|
use Doctrine\ORM\Mapping as ORM; |
9
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
10
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @ORM\Entity |
14
|
|
|
* @ORM\Table(name="movies_translations", |
15
|
|
|
* uniqueConstraints={ |
16
|
|
|
* @ORM\UniqueConstraint(name="idx_MovieTranslations_locale_movie_id", columns={"locale", "movie_id"}) |
17
|
|
|
* }) |
18
|
|
|
*/ |
19
|
|
|
class MovieTranslations implements EntityTranslationInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @ORM\Id() |
23
|
|
|
* @ORM\GeneratedValue() |
24
|
|
|
* @ORM\Column(type="integer") |
25
|
|
|
*/ |
26
|
|
|
private $id; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @Groups({"list", "view"}) |
30
|
|
|
* @ORM\Column(type="string", length=5) |
31
|
|
|
*/ |
32
|
|
|
private $locale; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @ORM\ManyToOne(targetEntity="App\Movies\Entity\Movie", inversedBy="translations") |
36
|
|
|
* @ORM\JoinColumn(nullable=false) |
37
|
|
|
*/ |
38
|
|
|
private $movie; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @ORM\Column(type="string", length=100) |
42
|
|
|
* @Groups({"list", "view"}) |
43
|
|
|
*/ |
44
|
|
|
private $title; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
48
|
|
|
* @Groups({"list", "view"}) |
49
|
|
|
*/ |
50
|
|
|
private $posterUrl; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @ORM\Column(type="text") |
54
|
|
|
* @Groups({"view"}) |
55
|
|
|
*/ |
56
|
|
|
private $overview; |
57
|
|
|
|
58
|
3 |
|
public function __construct(Movie $movie, MovieTranslationDTO $movieTranslationDTO) |
59
|
|
|
{ |
60
|
3 |
|
$this->movie = $movie; |
61
|
3 |
|
$this->locale = $movieTranslationDTO->getLocale(); |
62
|
3 |
|
$this->title = $movieTranslationDTO->getTitle(); |
63
|
3 |
|
$this->posterUrl = $movieTranslationDTO->getPosterUrl(); |
64
|
3 |
|
$this->overview = $movieTranslationDTO->getOverview(); |
65
|
3 |
|
} |
66
|
|
|
|
67
|
|
|
public function getId() |
68
|
|
|
{ |
69
|
|
|
return $this->id; |
70
|
|
|
} |
71
|
|
|
|
72
|
6 |
|
public function getTitle() |
73
|
|
|
{ |
74
|
6 |
|
return $this->title; |
75
|
|
|
} |
76
|
|
|
|
77
|
7 |
|
public function getLocale(): string |
78
|
|
|
{ |
79
|
7 |
|
return $this->locale; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return mixed |
84
|
|
|
*/ |
85
|
6 |
|
public function getPosterUrl() |
86
|
|
|
{ |
87
|
6 |
|
return $this->posterUrl; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return mixed |
92
|
|
|
*/ |
93
|
1 |
|
public function getOverview() |
94
|
|
|
{ |
95
|
1 |
|
return $this->overview; |
96
|
|
|
} |
97
|
|
|
} |