|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Uxmp\Core\Orm\Model; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
8
|
|
|
use Doctrine\Common\Collections\Collection; |
|
9
|
|
|
use Doctrine\DBAL\Types\Types; |
|
10
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
11
|
|
|
use Doctrine\ORM\Mapping\OrderBy; |
|
12
|
|
|
use Uxmp\Core\Orm\Repository\DiscRepository; |
|
13
|
|
|
|
|
14
|
|
|
#[ORM\Entity(repositoryClass: DiscRepository::class)] |
|
15
|
|
|
#[ORM\Table(name: 'disc')] |
|
16
|
|
|
#[ORM\UniqueConstraint(name: 'mbid_discnumber', columns: ['mbid', 'number'])] |
|
17
|
|
|
class Disc implements DiscInterface |
|
18
|
|
|
{ |
|
19
|
|
|
#[ORM\Column(type: Types::INTEGER)] |
|
20
|
|
|
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')] |
|
21
|
|
|
private int $id; |
|
22
|
|
|
|
|
23
|
|
|
#[ORM\Column(type: Types::INTEGER)] |
|
24
|
|
|
private int $album_id; |
|
25
|
|
|
|
|
26
|
|
|
#[ORM\Column(type: Types::INTEGER)] |
|
27
|
|
|
private int $number; |
|
28
|
|
|
|
|
29
|
|
|
#[ORM\Column(type: Types::STRING, length: 36, nullable: true)] |
|
30
|
|
|
private ?string $mbid = null; |
|
31
|
|
|
|
|
32
|
|
|
#[ORM\Column(type: Types::INTEGER, length: 6)] |
|
33
|
|
|
private int $length = 0; |
|
34
|
|
|
|
|
35
|
|
|
#[ORM\ManyToOne(targetEntity: AlbumInterface::class, inversedBy: 'discs')] |
|
36
|
|
|
#[ORM\JoinColumn(name: 'album_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] |
|
37
|
|
|
private AlbumInterface $album; |
|
38
|
|
|
|
|
39
|
|
|
/** @var Collection<int, SongInterface> */ |
|
40
|
|
|
#[ORM\OneToMany(mappedBy: 'disc', targetEntity: SongInterface::class, cascade: ['ALL'], indexBy: 'id')] |
|
41
|
|
|
#[OrderBy(['track_number' => 'ASC'])] |
|
42
|
|
|
private Collection $songs; |
|
43
|
|
|
|
|
44
|
7 |
|
public function __construct() |
|
45
|
|
|
{ |
|
46
|
7 |
|
$this->songs = new ArrayCollection(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function getId(): int |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->id; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
1 |
|
public function getSongs(): iterable |
|
55
|
|
|
{ |
|
56
|
1 |
|
return $this->songs; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
1 |
|
public function addSong(SongInterface $song): DiscInterface |
|
60
|
|
|
{ |
|
61
|
1 |
|
$this->songs->add($song); |
|
62
|
1 |
|
return $this; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
1 |
|
public function getMbid(): ?string |
|
66
|
|
|
{ |
|
67
|
1 |
|
return $this->mbid; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
1 |
|
public function setMbid(?string $mbid): DiscInterface |
|
71
|
|
|
{ |
|
72
|
1 |
|
$this->mbid = $mbid; |
|
73
|
1 |
|
return $this; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
1 |
|
public function getAlbumId(): int |
|
77
|
|
|
{ |
|
78
|
1 |
|
return $this->album_id; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
1 |
|
public function setAlbumId(int $album_id): DiscInterface |
|
82
|
|
|
{ |
|
83
|
1 |
|
$this->album_id = $album_id; |
|
84
|
1 |
|
return $this; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
1 |
|
public function getNumber(): int |
|
88
|
|
|
{ |
|
89
|
1 |
|
return $this->number; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
1 |
|
public function setNumber(int $number): DiscInterface |
|
93
|
|
|
{ |
|
94
|
1 |
|
$this->number = $number; |
|
95
|
1 |
|
return $this; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
1 |
|
public function getAlbum(): AlbumInterface |
|
99
|
|
|
{ |
|
100
|
1 |
|
return $this->album; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
1 |
|
public function setAlbum(AlbumInterface $album): DiscInterface |
|
104
|
|
|
{ |
|
105
|
1 |
|
$this->album = $album; |
|
106
|
1 |
|
return $this; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
1 |
|
public function getLength(): int |
|
110
|
|
|
{ |
|
111
|
1 |
|
return $this->length; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
1 |
|
public function setLength(int $length): DiscInterface |
|
115
|
|
|
{ |
|
116
|
1 |
|
$this->length = $length; |
|
117
|
1 |
|
return $this; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
1 |
|
public function getSongCount(): int |
|
121
|
|
|
{ |
|
122
|
1 |
|
return $this->songs->count(); |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|