ConfirmationEmailTemplate
1 month ago
ImportExport
2 weeks ago
RestApi
3 days ago
Statistics
1 month ago
BulkActionController.php
3 days ago
BulkActionException.php
1 month ago
BulkConfirmationEmailResender.php
2 months ago
ConfirmationEmailCustomizer.php
2 months ago
ConfirmationEmailMailer.php
2 months ago
ConfirmationEmailResolver.php
2 months ago
EngagementDataBackfiller.php
2 months ago
InactiveSubscribersController.php
4 days ago
LinkTokens.php
2 months ago
NewSubscriberNotificationMailer.php
2 months ago
RequiredCustomFieldValidator.php
2 months ago
SegmentsCountRecalculator.php
2 weeks ago
Source.php
2 months ago
SubscriberActions.php
2 months ago
SubscriberCustomFieldRepository.php
3 years ago
SubscriberIPsRepository.php
2 years ago
SubscriberLimitNotificationEvaluator.php
2 months ago
SubscriberLimitNotificationMailer.php
2 months ago
SubscriberLimitNotificationScheduler.php
2 months ago
SubscriberListingRepository.php
2 weeks ago
SubscriberPersonalDataEraser.php
2 months ago
SubscriberSaveController.php
3 days ago
SubscriberSegmentRepository.php
2 weeks ago
SubscriberSubscribeController.php
2 weeks ago
SubscriberTagRepository.php
4 years ago
SubscribersCountsController.php
2 weeks ago
SubscribersEmailCountsController.php
2 weeks ago
SubscribersRepository.php
3 days ago
TrackingConsentController.php
4 days ago
index.php
3 years ago
SubscriberLimitNotificationScheduler.php
46 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Subscribers; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Cron\CronWorkerScheduler; |
| 9 | use MailPoet\Cron\Workers\SubscriberLimitNotificationWorker; |
| 10 | use MailPoet\Entities\SubscriberEntity; |
| 11 | use MailPoet\WP\Functions as WPFunctions; |
| 12 | |
| 13 | class SubscriberLimitNotificationScheduler { |
| 14 | |
| 15 | /** @var CronWorkerScheduler */ |
| 16 | private $cronWorkerScheduler; |
| 17 | |
| 18 | /** @var WPFunctions */ |
| 19 | private $wp; |
| 20 | |
| 21 | public function __construct( |
| 22 | CronWorkerScheduler $cronWorkerScheduler, |
| 23 | WPFunctions $wp |
| 24 | ) { |
| 25 | $this->cronWorkerScheduler = $cronWorkerScheduler; |
| 26 | $this->wp = $wp; |
| 27 | } |
| 28 | |
| 29 | public function setupHooks(): void { |
| 30 | $this->wp->addAction( |
| 31 | SubscriberEntity::HOOK_SUBSCRIBERS_COUNT_CHANGED, |
| 32 | [$this, 'schedule'], |
| 33 | 10, |
| 34 | 1 |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * @param int[] $subscriberIds Subscriber IDs passed by the hook; the worker fetches a fresh count. |
| 40 | */ |
| 41 | public function schedule(array $subscriberIds = []): void { |
| 42 | unset($subscriberIds); |
| 43 | $this->cronWorkerScheduler->scheduleImmediatelyIfNotRunning(SubscriberLimitNotificationWorker::TASK_TYPE); |
| 44 | } |
| 45 | } |
| 46 |