Ejemplo n.º 1
0
 public function run()
 {
     $commands = $this->service->findCronCommands();
     $completedCommands = array();
     foreach ($commands as $commandDto) {
         /* @var $commandDto NEWSFEED_BOL_CronCommand */
         $command = trim($commandDto->command);
         if (empty($this->commands[$command])) {
             continue;
         }
         $method = $this->commands[$command];
         $data = json_decode($commandDto->data, true);
         $processData = json_decode($commandDto->processData, true);
         $r = $this->{$method}($data, $processData);
         if ($r === true) {
             $completedCommands[] = $commandDto->id;
         } else {
             $commandDto->processData = json_encode($r);
             $this->service->saveCronCommand($commandDto);
         }
     }
     if (!empty($completedCommands)) {
         $this->service->deleteCronCommands($completedCommands);
     }
 }