|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AudioCoreEntity\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
7
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
8
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
9
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
|
10
|
|
|
use Gedmo\Timestampable\Traits\TimestampableEntity; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Genre |
|
14
|
|
|
* |
|
15
|
|
|
* @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="name_idx", columns={"name"})}, options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"}) |
|
16
|
|
|
* @ORM\Entity |
|
17
|
|
|
*/ |
|
18
|
|
View Code Duplication |
class Genre |
|
19
|
|
|
{ |
|
20
|
|
|
use TimestampableEntity; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var integer |
|
24
|
|
|
* |
|
25
|
|
|
* @ORM\Column(name="id", type="integer") |
|
26
|
|
|
* @ORM\Id |
|
27
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
28
|
|
|
*/ |
|
29
|
|
|
private $id; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string |
|
33
|
|
|
* |
|
34
|
|
|
* @ORM\Column(name="name", type="string", length=50, nullable=false) |
|
35
|
|
|
* @Assert\NotBlank() |
|
36
|
|
|
* @Groups({"genre-read", "media-read"}) |
|
37
|
|
|
*/ |
|
38
|
|
|
private $name; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @ORM\ManyToMany(targetEntity="\AudioCoreEntity\Entity\Media",mappedBy="genres") |
|
42
|
|
|
* @Groups({"genre-read"}) |
|
43
|
|
|
**/ |
|
44
|
|
|
private $medias; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var string |
|
48
|
|
|
* @Gedmo\Slug(fields={"name"}, unique=true) |
|
49
|
|
|
* @ORM\Column(type="string", length=128, unique=true) |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $slug; |
|
52
|
|
|
|
|
53
|
3 |
|
public function __construct($name = null) |
|
54
|
|
|
{ |
|
55
|
3 |
|
$this->setName($name); |
|
56
|
3 |
|
$this->medias = new ArrayCollection(); |
|
57
|
3 |
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Get id |
|
61
|
|
|
* |
|
62
|
|
|
* @return integer |
|
63
|
|
|
*/ |
|
64
|
1 |
|
public function getId() |
|
65
|
|
|
{ |
|
66
|
1 |
|
return $this->id; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return string |
|
71
|
|
|
*/ |
|
72
|
1 |
|
public function getName() |
|
73
|
|
|
{ |
|
74
|
1 |
|
return $this->name; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param string $name |
|
79
|
|
|
* @return $this |
|
80
|
|
|
*/ |
|
81
|
3 |
|
public function setName($name) |
|
82
|
|
|
{ |
|
83
|
3 |
|
$this->name = $name; |
|
84
|
|
|
|
|
85
|
3 |
|
return $this; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @return mixed |
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function getMedias() |
|
92
|
|
|
{ |
|
93
|
1 |
|
return $this->medias; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @param mixed $medias |
|
98
|
|
|
* @return Genre |
|
99
|
|
|
*/ |
|
100
|
1 |
|
public function setMedias($medias) |
|
101
|
|
|
{ |
|
102
|
1 |
|
$this->medias = $medias; |
|
103
|
|
|
|
|
104
|
1 |
|
return $this; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return string |
|
109
|
|
|
*/ |
|
110
|
|
|
public function getSlug() |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->slug; |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|