1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace App\Genres\Entity; |
5
|
|
|
|
6
|
|
|
use App\Genres\Entity\GenreTranslations; |
7
|
|
|
use App\Translation\TranslatableTrait; |
8
|
|
|
use App\Translation\TranslatableInterface; |
9
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
10
|
|
|
use Doctrine\ORM\Mapping as ORM; |
11
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
12
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
13
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @ORM\Entity(repositoryClass="App\Genres\Repository\GenreRepository") |
17
|
|
|
* @ORM\Table(name="genres") |
18
|
|
|
* @method GenreTranslations getTranslation(string $locale, bool $useFallbackLocale = true) |
19
|
|
|
*/ |
20
|
|
|
class Genre implements TranslatableInterface |
21
|
|
|
{ |
22
|
|
|
use TranslatableTrait; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @ORM\Id() |
26
|
|
|
* @ORM\GeneratedValue() |
27
|
|
|
* @ORM\Column(type="integer") |
28
|
|
|
* @Groups({"list", "view"}) |
29
|
|
|
*/ |
30
|
|
|
private $id; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @ORM\Column(type="integer", options={"default": 0}) |
34
|
|
|
* @Groups({"ROLE_MODER", "ROLE_ADMIN"}) |
35
|
|
|
*/ |
36
|
|
|
private $tmdb_id; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var $translations GenreTranslations[]|ArrayCollection |
40
|
|
|
* @ORM\OneToMany(targetEntity="App\Genres\Entity\GenreTranslations", mappedBy="genre", cascade={"persist", "remove"}) |
41
|
|
|
* @Assert\Valid(traverse=true) |
42
|
|
|
* @Groups({"list", "view"}) |
43
|
|
|
*/ |
44
|
|
|
private $translations; |
45
|
|
|
|
46
|
2 |
|
public function __construct(?int $tmdb_id = 0) |
47
|
|
|
{ |
48
|
2 |
|
$this->translations = new ArrayCollection(); |
49
|
2 |
|
$this->tmdb_id = $tmdb_id ?? 0; |
50
|
2 |
|
} |
51
|
|
|
|
52
|
11 |
|
public function getId() |
53
|
|
|
{ |
54
|
11 |
|
return $this->id; |
55
|
|
|
} |
56
|
|
|
|
57
|
4 |
|
public function getTmdbId() |
58
|
|
|
{ |
59
|
4 |
|
return $this->tmdb_id; |
60
|
|
|
} |
61
|
|
|
} |