1 | <?php |
||
20 | class TaskRunner |
||
21 | { |
||
22 | /** |
||
23 | * The task manager. |
||
24 | * |
||
25 | * @var TaskManager |
||
26 | */ |
||
27 | protected $taskManager; |
||
28 | |||
29 | /** |
||
30 | * The output. |
||
31 | * |
||
32 | * @var OutputInterface |
||
33 | */ |
||
34 | protected $output; |
||
35 | |||
36 | /** |
||
37 | * The logger. |
||
38 | * |
||
39 | * @var null|LoggerInterface |
||
40 | */ |
||
41 | protected $logger; |
||
42 | |||
43 | /** |
||
44 | * Create task runner object. |
||
45 | * |
||
46 | * @param TaskManager $taskManager |
||
47 | * @param OutputInterface $output |
||
48 | * @param null|LoggerInterface $logger |
||
49 | */ |
||
50 | 4 | public function __construct(TaskManager $taskManager, OutputInterface $output, LoggerInterface $logger = null) |
|
56 | |||
57 | /** |
||
58 | * Gets called when the object is used as a callback. |
||
59 | * |
||
60 | * @param string $type |
||
61 | * @param string $buffer |
||
62 | * |
||
63 | * @return void |
||
64 | */ |
||
65 | 4 | public function __invoke($type, $buffer) |
|
70 | |||
71 | /** |
||
72 | * Log message. |
||
73 | * |
||
74 | * @param string $type |
||
75 | * @param string $message |
||
76 | * |
||
77 | * @return void |
||
78 | */ |
||
79 | 4 | protected function logMessage($type, $message) |
|
92 | |||
93 | /** |
||
94 | * Render output. |
||
95 | * |
||
96 | * @param string $type |
||
97 | * @param string $message |
||
98 | * |
||
99 | * @return void |
||
100 | */ |
||
101 | 4 | protected function renderOutput($type, $message) |
|
113 | |||
114 | /** |
||
115 | * Run all tasks from the task manager. |
||
116 | * |
||
117 | * @param int $timeout |
||
118 | * |
||
119 | * @return void |
||
120 | */ |
||
121 | 4 | public function runAll($timeout) |
|
127 | |||
128 | /** |
||
129 | * Run single task. |
||
130 | * |
||
131 | * @param Task $task |
||
132 | * @param int $timeout |
||
133 | * |
||
134 | * @return void |
||
135 | */ |
||
136 | 4 | public function run($task, $timeout) |
|
148 | } |
||
149 |