PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 4.2.1
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v4.2.1
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / Background / Job.php
Job.php
89 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SureCart\Background;
4
5 /**
6 * Abstract Job class.
7 *
8 * @abstract
9 * @extends BackgroundProcess
10 */
11 abstract class Job extends BackgroundProcess {
12 /**
13 * The next background process in the chain.
14 *
15 * @var BackgroundProcess
16 */
17 protected $next = null;
18
19 /**
20 * The task.
21 *
22 * @var \SureCart\Sync\Tasks\Task
23 */
24 protected $task;
25
26 /**
27 * Constructor.
28 *
29 * @param \SureCart\Sync\Tasks\Task $task The task.
30 */
31 public function __construct( $task ) {
32 parent::__construct();
33 $this->task = $task;
34 }
35
36 /**
37 * Bootstrap the background process.
38 *
39 * @return void
40 */
41 public function bootstrap() {
42 // we need to fake the dispatch method here because ajax handlers are only available in the constructor.
43 }
44
45 /**
46 * Job complete.
47 *
48 * @return void
49 */
50 protected function complete() {
51 parent::complete();
52
53 // run the next job in the chain.
54 if ( is_a( $this->next, self::class ) ) {
55 $this->next->dispatch();
56 }
57 }
58
59 /**
60 * Set the next background process in the chain.
61 *
62 * @param BackgroundProcess $next The next background process.
63 *
64 * @return $this
65 */
66 public function setNext( $next ) {
67 $this->next = $next;
68 return $this;
69 }
70
71 /**
72 * Get the task.
73 *
74 * @return \SureCart\Sync\Tasks\Task
75 */
76 public function getTask() {
77 return $this->task;
78 }
79
80 /**
81 * Is running.
82 *
83 * @return boolean
84 */
85 public function isRunning() {
86 return $this->is_active() || $this->task->showNotice();
87 }
88 }
89