/** * Waits on this workflow to finish * * @return [Workflow] $this */ public function wait() { while (!$this->isFinished()) { $this->fetch(); sleep(3); // TODO: output this to stdout so that it doesn't get mixed with any actual output. // We can't use the logger here because that might be redirected to a log-file and each line is timestamped. \Terminus::out("."); } // TODO: output this to stdout so that it doesn't get mixed with any actual output. \Terminus::line(); if ($this->isSuccessful()) { return $this; } else { $final_task = $this->get('final_task'); if ($final_task != null && !empty($final_task->messages)) { foreach ($final_task->messages as $data => $message) { throw new TerminusException($message->message); } } } }