private function executeBuildCommand(HarbormasterBuild $build, HarbormasterBuildTransaction $xaction) { $command = $xaction->getNewValue(); switch ($command) { case HarbormasterBuildCommand::COMMAND_RESTART: $issuable = $build->canRestartBuild(); break; case HarbormasterBuildCommand::COMMAND_PAUSE: $issuable = $build->canPauseBuild(); break; case HarbormasterBuildCommand::COMMAND_RESUME: $issuable = $build->canResumeBuild(); break; case HarbormasterBuildCommand::COMMAND_ABORT: $issuable = $build->canAbortBuild(); break; default: throw new Exception(pht('Unknown command %s', $command)); } if (!$issuable) { return; } $actor = $this->getActor(); if (!$build->canIssueCommand($actor, $command)) { return; } id(new HarbormasterBuildCommand())->setAuthorPHID($xaction->getAuthorPHID())->setTargetPHID($build->getPHID())->setCommand($command)->save(); PhabricatorWorker::scheduleTask('HarbormasterBuildWorker', array('buildID' => $build->getID()), array('objectPHID' => $build->getPHID())); }