Refactor the observers (#836)

This commit is contained in:
Phan An 2018-10-19 16:33:04 +02:00 committed by GitHub
parent 1c26d6bb66
commit ee6ac687c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -16,6 +16,11 @@ class AlbumObserver
}
public function deleted(Album $album): void
{
$this->deleteAlbumCover($album);
}
private function deleteAlbumCover(Album $album): void
{
if (!$album->has_cover) {
return;

View file

@ -15,6 +15,11 @@ class SongObserver
}
public function creating(Song $song): void
{
$this->setFileHashAsId($song);
}
private function setFileHashAsId(Song $song): void
{
$song->id = $this->helperService->getFileHash($song->path);
}