Sync post and newsletter

This commit is contained in:
Mike Jolley
2024-04-03 15:19:45 +01:00
committed by Aschepikov
parent 43752a7e39
commit f6a793d2e8
3 changed files with 41 additions and 0 deletions

View File

@@ -54,6 +54,17 @@ class EmailApiController {
$this->newsletterRepository->flush();
}
public function trashEmail(\WP_Post $wpPost) {
$newsletter = $this->newsletterRepository->findOneBy(['wpPost' => $wpPost->ID]);
if (!$newsletter) {
throw new NotFoundException('Newsletter was not found');
}
if ($newsletter->getWpPostId() !== $wpPost->ID) {
throw new UnexpectedValueException('Newsletter ID does not match the post ID');
}
$this->newsletterRepository->bulkTrash([$newsletter->getId()]);
}
public function getEmailDataSchema(): array {
return Builder::object([
'id' => Builder::integer()->nullable(),