Commit 56c3945f authored by SpinShare's avatar SpinShare

remove notifications if song was removed

parent 3cf24746
...@@ -17,6 +17,7 @@ use App\Entity\Song; ...@@ -17,6 +17,7 @@ use App\Entity\Song;
use App\Entity\User; use App\Entity\User;
use App\Entity\SongReport; use App\Entity\SongReport;
use App\Entity\UserReport; use App\Entity\UserReport;
use App\Entity\UserNotification;
use App\Entity\Promo; use App\Entity\Promo;
class ModactionsController extends AbstractController class ModactionsController extends AbstractController
...@@ -70,6 +71,12 @@ class ModactionsController extends AbstractController ...@@ -70,6 +71,12 @@ class ModactionsController extends AbstractController
} }
$em->remove($songToRemove); $em->remove($songToRemove);
$notifications = $em->getRepository(UserNotification::class)->findBy(array('connectedSong' => $songToRemove));
foreach($notifications as $notification) {
$em->remove($notification);
}
$em->flush(); $em->flush();
return $this->redirectToRoute('user.detail', array('userId' => $uploader->getId())); return $this->redirectToRoute('user.detail', array('userId' => $uploader->getId()));
...@@ -136,6 +143,12 @@ class ModactionsController extends AbstractController ...@@ -136,6 +143,12 @@ class ModactionsController extends AbstractController
} catch ( \Exception $e ) { } } catch ( \Exception $e ) { }
$em->remove($reportSong); $em->remove($reportSong);
$notifications = $em->getRepository(UserNotification::class)->findBy(array('connectedSong' => $reportSong));
foreach($notifications as $notification) {
$em->remove($notification);
}
$em->flush(); $em->flush();
return $this->redirectToRoute('moderation.reports.song', array('reportId' => $reportId)); return $this->redirectToRoute('moderation.reports.song', array('reportId' => $reportId));
......
...@@ -440,6 +440,12 @@ class SongController extends AbstractController ...@@ -440,6 +440,12 @@ class SongController extends AbstractController
// remove the entity // remove the entity
$em->remove($result); $em->remove($result);
$notifications = $em->getRepository(UserNotification::class)->findBy(array('connectedSong' => $songId));
foreach($notifications as $notification) {
$em->remove($notification);
}
$em->flush(); $em->flush();
// reditect // reditect
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment