コード例 #1
0
ファイル: CronEdit.php プロジェクト: danzabar/alice
 /**
  * Fire the command
  *
  * @return void
  * @author Dan Cox
  */
 public function fire()
 {
     $name = $this->input->getArgument('name');
     $cmd = $this->input->getOption('cmd');
     $commandList = $this->input->getOption('commandlist');
     $time = $this->input->getOption('time');
     if (Cron::exists($name, 'name')) {
         $cron = Cron::db()->first(['name' => $name]);
         if (!empty($cmd)) {
             $cron->job = $cmd;
             $cron->command = NULL;
         } elseif (!empty($commandList)) {
             if (Command::exists($commandList, 'name')) {
                 $cron->job = NULL;
                 $cron->command = $commandList;
             } else {
                 throw new \RuntimeException("Command list does not exist");
             }
         }
         // Update the time if its set
         if (!empty($time)) {
             $cron->jobdate = $time;
         }
         $cron->save();
         $this->output->writeln('Saved updates to cron');
         return;
     }
     throw new \RuntimeException("The cron you specified does not exist");
 }
コード例 #2
0
ファイル: Cron.php プロジェクト: danzabar/alice
 /**
  * Updates the crontab file from the database cron jobs
  *
  * @return void
  * @author Dan Cox
  */
 public function updateFromDB()
 {
     $crons = CronModel::db()->get();
     $file = '';
     foreach ($crons as $cron) {
         $file .= $cron->jobdate . " /usr/bin/php " . ROOT . "alice cron:run " . $cron->id . "\n";
     }
     $this->writeTo($file);
 }
コード例 #3
0
ファイル: CronRun.php プロジェクト: danzabar/alice
 /**
  * Fire command
  *
  * @return void
  * @author Dan Cox
  */
 public function fire()
 {
     if (Cron::exists($this->input->getArgument('cronid'))) {
         $this->cron = Cron::db()->find($this->input->getArgument('cronid'));
         if (!is_null($this->cron->job)) {
             $this->runCronFromJob();
         } else {
             $this->runCronFromCommandList();
         }
         return true;
     }
     throw new \RuntimeException('The cron specified does not exist');
 }
コード例 #4
0
ファイル: CronRemove.php プロジェクト: danzabar/alice
 /**
  * Fire the command
  *
  * @return void
  * @author Dan Cox
  */
 public function fire()
 {
     $name = $this->input->getArgument('name');
     if (Cron::exists([$name, 'name'])) {
         $cron = Cron::db()->first(['name', $name]);
         $cron->delete();
         // Rebuild the crons
         $this->get('cron')->updateFromDB();
         $this->output->writeln('Removed and updated cron list');
         return;
     }
     throw new \RuntimeException('The cron you specified does not exist');
 }
コード例 #5
0
ファイル: CronCreate.php プロジェクト: danzabar/alice
 /**
  * Creates the cron from the command list option
  *
  * @return void
  * @author Dan Cox
  */
 public function createCronFromCommandList()
 {
     $cron = new Cron();
     $cron->name = $this->input->getArgument('name');
     $cron->command = $this->input->getOption('commandlist');
     $cron->jobdate = $this->input->getArgument('time');
     $cron->createdAt = new \Datetime('NOW');
     $cron->updatedAt = new \Datetime('NOW');
     $cron->save();
     $this->cron->updateFromDB();
 }