mirror of
https://github.com/koel/koel
synced 2024-11-10 14:44:13 +00:00
Refactor the observers (#836)
This commit is contained in:
parent
1c26d6bb66
commit
ee6ac687c4
2 changed files with 10 additions and 0 deletions
|
@ -16,6 +16,11 @@ class AlbumObserver
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleted(Album $album): void
|
public function deleted(Album $album): void
|
||||||
|
{
|
||||||
|
$this->deleteAlbumCover($album);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function deleteAlbumCover(Album $album): void
|
||||||
{
|
{
|
||||||
if (!$album->has_cover) {
|
if (!$album->has_cover) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -15,6 +15,11 @@ class SongObserver
|
||||||
}
|
}
|
||||||
|
|
||||||
public function creating(Song $song): void
|
public function creating(Song $song): void
|
||||||
|
{
|
||||||
|
$this->setFileHashAsId($song);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setFileHashAsId(Song $song): void
|
||||||
{
|
{
|
||||||
$song->id = $this->helperService->getFileHash($song->path);
|
$song->id = $this->helperService->getFileHash($song->path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue