/**
  * Example run function.
  * This function is executed, when a worker is executing a task.
  * The return parameter will determine, if the task will be marked completed, or be requeued.
  *
  * @param array $data The array passed to QueuedTask->createJob()
  * @param int $id The id of the QueuedTask
  * @return bool Success
  * @throws RuntimeException when seconds are 0;
  */
 public function run($data, $id = null)
 {
     $this->hr();
     $this->out('CakePHP Queue LongExample task.');
     $seconds = (int) $data;
     if (!$seconds) {
         throw new RuntimeException('Seconds need to be > 0');
     }
     $this->out('A total of ' . $seconds . ' seconds need to pass...');
     for ($i = 0; $i < $seconds; $i++) {
         sleep(1);
         $this->QueuedTask->updateProgress($id, ($i + 1) / $seconds);
     }
     $this->hr();
     $this->out(' ->Success, the LongExample Job was run.<-');
     $this->out(' ');
     $this->out(' ');
     return true;
 }