|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Uxmp\Core\Orm\Model; |
|
6
|
|
|
|
|
7
|
|
|
use DateTimeInterface; |
|
8
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
9
|
|
|
use Doctrine\Common\Collections\Collection; |
|
10
|
|
|
use Doctrine\DBAL\Types\Types; |
|
11
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
12
|
|
|
use JetBrains\PhpStorm\Pure; |
|
13
|
|
|
use Uxmp\Core\Orm\Repository\ArtistRepository; |
|
14
|
|
|
|
|
15
|
|
|
#[ORM\Entity(repositoryClass: ArtistRepository::class)] |
|
16
|
|
|
#[ORM\Table(name: 'artist')] |
|
17
|
|
|
class Artist implements ArtistInterface |
|
18
|
|
|
{ |
|
19
|
|
|
#[ORM\Column(type: Types::INTEGER)] |
|
20
|
|
|
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')] |
|
21
|
|
|
private int $id; |
|
22
|
|
|
|
|
23
|
|
|
#[ORM\Column(type: Types::STRING, nullable: true)] |
|
24
|
|
|
private ?string $title = null; |
|
25
|
|
|
|
|
26
|
|
|
#[ORM\Column(type: Types::STRING, nullable: true)] |
|
27
|
|
|
private ?string $searchTitle = ''; |
|
28
|
|
|
|
|
29
|
|
|
#[ORM\Column(type: Types::STRING, length: 36, unique: true, nullable: true)] |
|
30
|
|
|
private ?string $mbid = null; |
|
31
|
|
|
|
|
32
|
|
|
/** @var Collection<int, AlbumInterface> */ |
|
33
|
|
|
#[ORM\OneToMany(mappedBy: 'artist', targetEntity: AlbumInterface::class, cascade: ['ALL'], indexBy: 'id')] |
|
34
|
|
|
private Collection $albums; |
|
35
|
|
|
|
|
36
|
|
|
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] |
|
37
|
|
|
private DateTimeInterface $last_modified; |
|
38
|
|
|
|
|
39
|
8 |
|
#[Pure] |
|
40
|
|
|
public function __construct() |
|
41
|
|
|
{ |
|
42
|
8 |
|
$this->albums = new ArrayCollection(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function getId(): int |
|
46
|
|
|
{ |
|
47
|
|
|
return $this->id; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
1 |
|
public function getTitle(): ?string |
|
51
|
|
|
{ |
|
52
|
1 |
|
return $this->title; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
1 |
|
public function setTitle(?string $title): ArtistInterface |
|
56
|
|
|
{ |
|
57
|
1 |
|
$this->title = $title; |
|
58
|
1 |
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function getSearchTitle(): string |
|
62
|
|
|
{ |
|
63
|
|
|
return (string) $this->searchTitle; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function setSearchTitle(string $searchTitle): ArtistInterface |
|
67
|
|
|
{ |
|
68
|
|
|
$this->searchTitle = $searchTitle; |
|
69
|
|
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
1 |
|
public function getAlbums(): iterable |
|
73
|
|
|
{ |
|
74
|
1 |
|
return $this->albums; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
1 |
|
public function addAlbum(AlbumInterface $album): ArtistInterface |
|
78
|
|
|
{ |
|
79
|
1 |
|
$this->albums->add($album); |
|
80
|
1 |
|
return $this; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
2 |
|
public function getMbid(): ?string |
|
84
|
|
|
{ |
|
85
|
2 |
|
return $this->mbid; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
2 |
|
public function setMbid(?string $mbid): ArtistInterface |
|
89
|
|
|
{ |
|
90
|
2 |
|
$this->mbid = $mbid; |
|
91
|
2 |
|
return $this; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
1 |
|
#[Pure] |
|
95
|
|
|
public function getArtItemType(): string |
|
96
|
|
|
{ |
|
97
|
1 |
|
return 'artist'; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
1 |
|
#[Pure] |
|
101
|
|
|
public function getArtItemId(): ?string |
|
102
|
|
|
{ |
|
103
|
1 |
|
return $this->getMbid(); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
1 |
|
public function getLastModified(): ?DateTimeInterface |
|
107
|
|
|
{ |
|
108
|
1 |
|
return $this->last_modified; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
1 |
|
public function setLastModified(DateTimeInterface $last_modified): ArtistInterface |
|
112
|
|
|
{ |
|
113
|
1 |
|
$this->last_modified = $last_modified; |
|
114
|
1 |
|
return $this; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
1 |
|
public function getAlbumCount(): int |
|
118
|
|
|
{ |
|
119
|
1 |
|
return $this->albums->count(); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|