Differential D13874 Diff 33503 src/applications/harbormaster/conduit/HarbormasterAppendLogConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/conduit/HarbormasterAppendLogConduitAPIMethod.php
- This file was added.
| <?php | |||||
| final class HarbormasterAppendLogConduitAPIMethod | |||||
| extends HarbormasterConduitAPIMethod { | |||||
| public function getAPIMethodName() { | |||||
| return 'harbormaster.appendlog'; | |||||
| } | |||||
| public function getMethodDescription() { | |||||
| return pht( | |||||
| 'Appends data to a Harbormaster log that was started '. | |||||
| 'with harbormaster.startlog.'); | |||||
| } | |||||
| protected function defineParamTypes() { | |||||
| return array( | |||||
| 'buildLogPHID' => 'required phid', | |||||
| 'data' => 'required string', | |||||
| ); | |||||
| } | |||||
| protected function defineReturnType() { | |||||
| return 'void'; | |||||
| } | |||||
| protected function execute(ConduitAPIRequest $request) { | |||||
| $viewer = $request->getUser(); | |||||
| $build_log_phid = $request->getValue('buildLogPHID'); | |||||
| $data = $request->getValue('data'); | |||||
| $build_log = id(new HarbormasterBuildLogQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withPHIDs(array($build_log_phid)) | |||||
| ->executeOne(); | |||||
| if (!$build_log) { | |||||
| throw new Exception(pht('No such build log!')); | |||||
| } | |||||
| $build_log->append($data); | |||||
| return null; | |||||
| } | |||||
| } | |||||