Cleanup
1 year ago
Sync
1 year ago
CleanupJob.php
1 year ago
JobService.php
1 year ago
SyncJob.php
1 year ago
CleanupJob.php
64 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Sync\Jobs; |
| 4 | |
| 5 | /** |
| 6 | * Cleanup job. |
| 7 | * |
| 8 | * Handles the cleanup job for the products. |
| 9 | */ |
| 10 | class CleanupJob { |
| 11 | /** |
| 12 | * The app. |
| 13 | * |
| 14 | * @var \SureCart\App |
| 15 | */ |
| 16 | protected $app; |
| 17 | |
| 18 | /** |
| 19 | * Constructor. |
| 20 | * |
| 21 | * @param \SureCart\App $app The app. |
| 22 | */ |
| 23 | public function __construct( $app ) { |
| 24 | $this->app = $app; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Get the queue process. |
| 29 | * |
| 30 | * @return \SureCart\Sync\QueueProcess |
| 31 | */ |
| 32 | public function products() { |
| 33 | return $this->app->resolve( 'surecart.jobs.cleanup.products' ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get the collections process. |
| 38 | * |
| 39 | * @return \SureCart\Sync\CollectionsProcess |
| 40 | */ |
| 41 | public function collections() { |
| 42 | return $this->app->resolve( 'surecart.jobs.cleanup.collections' ); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Cancel all jobs. |
| 47 | * |
| 48 | * @return void |
| 49 | */ |
| 50 | public function cancel() { |
| 51 | $this->products()->cancel(); |
| 52 | $this->collections()->cancel(); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Is the cleanup active? |
| 57 | * |
| 58 | * @return boolean |
| 59 | */ |
| 60 | public function isActive() { |
| 61 | return $this->products()->isRunning() || $this->collections()->isRunning(); |
| 62 | } |
| 63 | } |
| 64 |