mangaRepository->find($message->getMangaId()); if (!$manga) { return; } $lastChapters = $this->mangadexProvider->addAllChaptersToManga($manga); try { foreach ($manga->getChapters() as $chapter) { $this->entityManager->persist($chapter); } $this->entityManager->persist($manga); $this->entityManager->flush(); } catch (\Exception $e) { if ($e instanceof UniqueConstraintViolationException) { $this->notificationService->sendUpdate(['status' => 'error', 'message' => 'An error occurred while refreshing ' . $manga->getTitle() . '.']); return; } } $this->notificationService->sendUpdate(['status' => 'success', 'message' => $manga->getTitle() . ' refreshed, ' . count($lastChapters) . ' new chapters added.']); } }