Skip to content

Commit 6532db0

Browse files
committed
Add flush after delete
1 parent eaa26fc commit 6532db0

14 files changed

+48
-7
lines changed

src/Identity/Controller/AdminAttributeDefinitionController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpList\RestBundle\Identity\Controller;
66

7+
use Doctrine\ORM\EntityManagerInterface;
78
use OpenApi\Attributes as OA;
89
use PhpList\Core\Domain\Identity\Model\AdminAttributeDefinition;
910
use PhpList\Core\Domain\Identity\Service\AdminAttributeDefinitionManager;
@@ -32,7 +33,8 @@ public function __construct(
3233
RequestValidator $validator,
3334
AdminAttributeDefinitionManager $definitionManager,
3435
AdminAttributeDefinitionNormalizer $normalizer,
35-
PaginatedDataProvider $paginatedDataProvider
36+
PaginatedDataProvider $paginatedDataProvider,
37+
private readonly EntityManagerInterface $entityManager,
3638
) {
3739
parent::__construct($authentication, $validator);
3840
$this->definitionManager = $definitionManager;
@@ -211,6 +213,7 @@ public function delete(
211213
}
212214

213215
$this->definitionManager->delete($attributeDefinition);
216+
$this->entityManager->flush();
214217

215218
return $this->json(null, Response::HTTP_NO_CONTENT);
216219
}

src/Identity/Controller/AdminAttributeValueController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public function delete(
198198
throw $this->createNotFoundException('Administrator attribute not found.');
199199
}
200200
$this->attributeManager->delete($attribute);
201+
$this->entityManager->flush();
201202

202203
return $this->json(null, Response::HTTP_NO_CONTENT);
203204
}
@@ -355,6 +356,7 @@ public function getAttributeDefinition(
355356
attributeDefinitionId: $definition->getId()
356357
);
357358
$this->attributeManager->delete($attribute);
359+
$this->entityManager->flush();
358360

359361
return $this->json(
360362
$this->normalizer->normalize($attribute),

src/Identity/Controller/SessionController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpList\RestBundle\Identity\Controller;
66

7+
use Doctrine\ORM\EntityManagerInterface;
78
use OpenApi\Attributes as OA;
89
use PhpList\Core\Domain\Identity\Model\AdministratorToken;
910
use PhpList\Core\Domain\Identity\Service\SessionManager;
@@ -34,6 +35,7 @@ public function __construct(
3435
Authentication $authentication,
3536
RequestValidator $validator,
3637
SessionManager $sessionManager,
38+
private readonly EntityManagerInterface $entityManager,
3739
) {
3840
parent::__construct($authentication, $validator);
3941

@@ -96,6 +98,7 @@ public function createSession(
9698
loginName:$createSessionRequest->loginName,
9799
password: $createSessionRequest->password
98100
);
101+
$this->entityManager->flush();
99102

100103
$json = $normalizer->normalize($token, 'json');
101104

@@ -163,6 +166,7 @@ public function deleteSession(
163166
}
164167

165168
$this->sessionManager->deleteSession($token);
169+
$this->entityManager->flush();
166170

167171
return $this->json(null, Response::HTTP_NO_CONTENT);
168172
}

src/Messaging/Controller/BounceRegexController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpList\RestBundle\Messaging\Controller;
66

7+
use Doctrine\ORM\EntityManagerInterface;
78
use OpenApi\Attributes as OA;
89
use PhpList\Core\Domain\Messaging\Service\Manager\BounceRegexManager;
910
use PhpList\Core\Security\Authentication;
@@ -27,6 +28,7 @@ public function __construct(
2728
RequestValidator $validator,
2829
private readonly BounceRegexManager $manager,
2930
private readonly BounceRegexNormalizer $normalizer,
31+
private readonly EntityManagerInterface $entityManager,
3032
) {
3133
parent::__construct($authentication, $validator);
3234
}
@@ -240,6 +242,7 @@ public function delete(Request $request, string $regexHash): JsonResponse
240242
throw $this->createNotFoundException('Bounce regex not found.');
241243
}
242244
$this->manager->delete($entity);
245+
$this->entityManager->flush();
243246

244247
return $this->json(null, Response::HTTP_NO_CONTENT);
245248
}

src/Messaging/Controller/CampaignController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace PhpList\RestBundle\Messaging\Controller;
66

7+
use Doctrine\ORM\EntityManagerInterface;
78
use OpenApi\Attributes as OA;
9+
use PhpList\Core\Domain\Messaging\Message\CampaignProcessorMessage;
810
use PhpList\Core\Domain\Messaging\Model\Message;
911
use PhpList\Core\Security\Authentication;
1012
use PhpList\RestBundle\Common\Controller\BaseController;
@@ -36,6 +38,7 @@ public function __construct(
3638
RequestValidator $validator,
3739
CampaignService $campaignService,
3840
MessageBusInterface $messageBus,
41+
private readonly EntityManagerInterface $entityManager,
3942
) {
4043
parent::__construct($authentication, $validator);
4144
$this->campaignService = $campaignService;
@@ -340,6 +343,7 @@ public function deleteMessage(
340343
$authUser = $this->requireAuthentication($request);
341344

342345
$this->campaignService->deleteMessage($authUser, $message);
346+
$this->entityManager->flush();
343347

344348
return $this->json(null, Response::HTTP_NO_CONTENT);
345349
}

src/Messaging/Controller/TemplateController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpList\RestBundle\Messaging\Controller;
66

7+
use Doctrine\ORM\EntityManagerInterface;
78
use OpenApi\Attributes as OA;
89
use PhpList\Core\Domain\Messaging\Model\Template;
910
use PhpList\Core\Domain\Messaging\Service\Manager\TemplateManager;
@@ -37,6 +38,7 @@ public function __construct(
3738
TemplateNormalizer $normalizer,
3839
TemplateManager $templateManager,
3940
PaginatedDataProvider $paginatedDataProvider,
41+
private readonly EntityManagerInterface $entityManager,
4042
) {
4143
parent::__construct($authentication, $validator);
4244
$this->normalizer = $normalizer;
@@ -318,6 +320,7 @@ public function delete(
318320
}
319321

320322
$this->templateManager->delete($template);
323+
$this->entityManager->flush();
321324

322325
return $this->json(null, Response::HTTP_NO_CONTENT);
323326
}

src/Messaging/Service/CampaignService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpList\RestBundle\Messaging\Service;
66

7+
use Doctrine\ORM\EntityManagerInterface;
78
use PhpList\Core\Domain\Identity\Model\Administrator;
89
use PhpList\Core\Domain\Identity\Model\PrivilegeFlag;
910
use PhpList\Core\Domain\Messaging\Model\Filter\MessageFilter;
@@ -23,6 +24,7 @@ public function __construct(
2324
private readonly MessageManager $messageManager,
2425
private readonly PaginatedDataProvider $paginatedProvider,
2526
private readonly MessageNormalizer $normalizer,
27+
private readonly EntityManagerInterface $entityManager,
2628
) {
2729
}
2830

@@ -86,5 +88,6 @@ public function deleteMessage(Administrator $administrator, Message $message = n
8688
}
8789

8890
$this->messageManager->delete($message);
91+
$this->entityManager->flush();
8992
}
9093
}

src/Subscription/Controller/SubscribePageController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpList\RestBundle\Subscription\Controller;
66

7+
use Doctrine\ORM\EntityManagerInterface;
78
use OpenApi\Attributes as OA;
89
use PhpList\Core\Domain\Identity\Model\PrivilegeFlag;
910
use PhpList\Core\Domain\Subscription\Model\SubscribePage;
@@ -28,6 +29,7 @@ public function __construct(
2829
RequestValidator $validator,
2930
private readonly SubscribePageManager $subscribePageManager,
3031
private readonly SubscribePageNormalizer $normalizer,
32+
private readonly EntityManagerInterface $entityManager,
3133
) {
3234
parent::__construct($authentication, $validator);
3335
}
@@ -141,6 +143,7 @@ public function createPage(Request $request): JsonResponse
141143
$createRequest = $this->validator->validate($request, SubscribePageRequest::class);
142144

143145
$page = $this->subscribePageManager->createPage($createRequest->title, $createRequest->active, $admin);
146+
$this->entityManager->flush();
144147

145148
return $this->json($this->normalizer->normalize($page), Response::HTTP_CREATED);
146149
}

src/Subscription/Controller/SubscriberAttributeDefinitionController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpList\RestBundle\Subscription\Controller;
66

7+
use Doctrine\ORM\EntityManagerInterface;
78
use OpenApi\Attributes as OA;
89
use PhpList\Core\Domain\Subscription\Model\SubscriberAttributeDefinition;
910
use PhpList\Core\Domain\Subscription\Service\Manager\AttributeDefinitionManager;
@@ -32,7 +33,8 @@ public function __construct(
3233
RequestValidator $validator,
3334
AttributeDefinitionManager $definitionManager,
3435
AttributeDefinitionNormalizer $normalizer,
35-
PaginatedDataProvider $paginatedDataProvider
36+
PaginatedDataProvider $paginatedDataProvider,
37+
private readonly EntityManagerInterface $entityManager,
3638
) {
3739
parent::__construct($authentication, $validator);
3840
$this->definitionManager = $definitionManager;
@@ -209,6 +211,7 @@ public function delete(
209211
}
210212

211213
$this->definitionManager->delete($attributeDefinition);
214+
$this->entityManager->flush();
212215

213216
return $this->json(null, Response::HTTP_NO_CONTENT);
214217
}

src/Subscription/Controller/SubscriberAttributeValueController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpList\RestBundle\Subscription\Controller;
66

7+
use Doctrine\ORM\EntityManagerInterface;
78
use OpenApi\Attributes as OA;
89
use PhpList\Core\Domain\Subscription\Model\Filter\SubscriberAttributeValueFilter;
910
use PhpList\Core\Domain\Subscription\Model\Subscriber;
@@ -33,7 +34,8 @@ public function __construct(
3334
RequestValidator $validator,
3435
SubscriberAttributeManager $attributeManager,
3536
SubscriberAttributeValueNormalizer $normalizer,
36-
PaginatedDataProvider $paginatedDataProvider
37+
PaginatedDataProvider $paginatedDataProvider,
38+
private readonly EntityManagerInterface $entityManager,
3739
) {
3840
parent::__construct($authentication, $validator);
3941
$this->attributeManager = $attributeManager;
@@ -193,6 +195,7 @@ public function delete(
193195
throw $this->createNotFoundException('Subscriber attribute not found.');
194196
}
195197
$this->attributeManager->delete($attribute);
198+
$this->entityManager->flush();
196199

197200
return $this->json(null, Response::HTTP_NO_CONTENT);
198201
}
@@ -349,6 +352,7 @@ public function getAttributeDefinition(
349352
}
350353
$attribute = $this->attributeManager->getSubscriberAttribute($subscriber->getId(), $definition->getId());
351354
$this->attributeManager->delete($attribute);
355+
$this->entityManager->flush();
352356

353357
return $this->json(
354358
$this->normalizer->normalize($attribute),

0 commit comments

Comments
 (0)