feat: connector on watchlist

This commit is contained in:
Maël Gangloff
2024-07-30 21:34:48 +02:00
parent 73a47c7879
commit 6f89317edc
7 changed files with 114 additions and 82 deletions

View File

@@ -2,10 +2,8 @@
namespace App\Controller;
use App\Config\TriggerAction;
use App\Entity\User;
use App\Entity\WatchList;
use App\Entity\WatchListTrigger;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
@@ -55,13 +53,6 @@ class WatchListController extends AbstractController
{
$watchList = $this->serializer->deserialize($request->getContent(), WatchList::class, 'json', ['groups' => 'watchlist:create']);
$watchList->setUser($this->getUser());
/** @var WatchListTrigger $trigger */
foreach ($watchList->getWatchListTriggers()->toArray() as $trigger) {
if ($trigger->getAction() === TriggerAction::SendEmail && $trigger->getConnector() !== null)
throw new Exception('No connector needed to send email');
if ($trigger->getAction() === TriggerAction::BuyDomain && $trigger->getConnector() === null)
throw new Exception('Unable to order a domain name without a Connector');
}
$this->em->persist($watchList);
$this->em->flush();