PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.5.9
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.5.9
1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / src / Jobs / ImportJob.php
hostinger-reach / src / Jobs Last commit date
AbandonedCartsJob.php 7 months ago AbstractBatchedJob.php 7 months ago AbstractJob.php 5 months ago ActionScheduler.php 7 months ago CleanupCartsJob.php 2 weeks ago ImportJob.php 7 months ago JobInterface.php 8 months ago RecurringJobInterface.php 8 months ago
ImportJob.php
51 lines
1 <?php
2
3 namespace Hostinger\Reach\Jobs;
4
5 use Hostinger\Reach\Api\Handlers\ReachApiHandler;
6 use Hostinger\Reach\Integrations\ImportManager;
7
8 class ImportJob extends AbstractBatchedJob {
9
10 public const JOB_NAME = 'import';
11
12 public ImportManager $import_manager;
13
14 public function __construct( ActionScheduler $action_scheduler, ReachApiHandler $reach_api_handler, ImportManager $import_manager ) {
15 parent::__construct( $action_scheduler, $reach_api_handler );
16 $this->import_manager = $import_manager;
17 }
18
19 public function get_name(): string {
20 return self::JOB_NAME;
21 }
22
23 protected function get_batch_size(): int {
24 return 50;
25 }
26
27 protected function get_batch( int $batch_number, array $args ): array {
28 $limit = $this->get_batch_size();
29 $integration = $args['integration'];
30 $form_id = $args['form_id'] ?? null;
31 return $this->import_manager->get_contacts( $integration, $form_id, $limit, ( $batch_number - 1 ) * $limit );
32 }
33
34 protected function process_items( array $args = array() ): void {
35 $items = $args['items'] ?? array();
36
37 if ( empty( $items ) ) {
38 return;
39 }
40
41 $this->reach_api_handler->post_import_contacts( $items );
42 }
43
44 protected function handle_complete( int $final_batch_number, array $args ): void {
45 parent::handle_complete( $final_batch_number, $args );
46 $integration = $args['integration'];
47 $form_id = $args['form_id'] ?? null;
48 $this->import_manager->set_completed_import( $integration, array( $form_id ) );
49 }
50 }
51