コード例 #1
0
 private function executeBuildCommand(HarbormasterBuild $build, HarbormasterBuildTransaction $xaction)
 {
     $command = $xaction->getNewValue();
     switch ($command) {
         case HarbormasterBuildCommand::COMMAND_RESTART:
             $issuable = $build->canRestartBuild();
             break;
         case HarbormasterBuildCommand::COMMAND_STOP:
             $issuable = $build->canStopBuild();
             break;
         case HarbormasterBuildCommand::COMMAND_RESUME:
             $issuable = $build->canResumeBuild();
             break;
         default:
             throw new Exception(pht('Unknown command %s', $command));
     }
     if (!$issuable) {
         return;
     }
     id(new HarbormasterBuildCommand())->setAuthorPHID($xaction->getAuthorPHID())->setTargetPHID($build->getPHID())->setCommand($command)->save();
     PhabricatorWorker::scheduleTask('HarbormasterBuildWorker', array('buildID' => $build->getID()));
 }