Editor
2 months ago
Embed
1 month ago
Links
2 months ago
Listing
9 months ago
Options
2 years ago
Preview
1 month ago
Renderer
5 days ago
RestApi
1 week ago
Scheduler
5 days ago
Segment
1 year ago
Sending
1 week ago
Sharing
1 month ago
Shortcodes
4 days ago
Statistics
1 week ago
ViewInBrowser
1 month ago
ApiDataSanitizer.php
3 years ago
AutomatedLatestContent.php
2 months ago
AutomaticEmailsRepository.php
3 years ago
BlockPostQuery.php
2 months ago
BulkActionController.php
2 months ago
BulkActionException.php
2 months ago
DynamicProducts.php
11 months ago
NewsletterCoupon.php
2 months ago
NewsletterDeleteController.php
2 years ago
NewsletterHtmlSanitizer.php
2 years ago
NewsletterPostsRepository.php
2 years ago
NewsletterResendController.php
5 days ago
NewsletterSaveController.php
1 month ago
NewsletterValidator.php
1 year ago
NewslettersRepository.php
2 weeks ago
StatusController.php
2 months ago
Url.php
2 months ago
index.php
3 years ago
NewsletterPostsRepository.php
35 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Newsletter; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Doctrine\Repository; |
| 9 | use MailPoet\Entities\NewsletterPostEntity; |
| 10 | |
| 11 | /** |
| 12 | * @extends Repository<NewsletterPostEntity> |
| 13 | */ |
| 14 | class NewsletterPostsRepository extends Repository { |
| 15 | protected function getEntityClassName() { |
| 16 | return NewsletterPostEntity::class; |
| 17 | } |
| 18 | |
| 19 | /** @param int[] $ids */ |
| 20 | public function deleteByNewsletterIds(array $ids): void { |
| 21 | $this->entityManager->createQueryBuilder() |
| 22 | ->delete(NewsletterPostEntity::class, 'p') |
| 23 | ->where('p.newsletter IN (:ids)') |
| 24 | ->setParameter('ids', $ids) |
| 25 | ->getQuery() |
| 26 | ->execute(); |
| 27 | |
| 28 | // delete was done via DQL, make sure the entities are also detached from the entity manager |
| 29 | $this->detachAll(function (NewsletterPostEntity $entity) use ($ids) { |
| 30 | $newsletter = $entity->getNewsletter(); |
| 31 | return $newsletter && in_array($newsletter->getId(), $ids, true); |
| 32 | }); |
| 33 | } |
| 34 | } |
| 35 |