Differential D16887 Diff 40656 src/applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | $build_target = id(new HarbormasterBuildTargetQuery()) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$build_target) { | if (!$build_target) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'No such build target "%s"!', | 'No such build target "%s"!', | ||||
$build_target_phid)); | $build_target_phid)); | ||||
} | } | ||||
$artifact_type = $request->getValue('artifactType'); | |||||
// Cast "artifactData" parameters to acceptable types if this request | |||||
// is submitting raw HTTP parameters. This is not ideal. See T11887 for | |||||
// discussion. | |||||
$artifact_data = $request->getValue('artifactData'); | |||||
if (!$request->getIsStrictlyTyped()) { | |||||
$impl = HarbormasterArtifact::getArtifactType($artifact_type); | |||||
if ($impl) { | |||||
foreach ($artifact_data as $key => $value) { | |||||
$artifact_data[$key] = $impl->readArtifactHTTPParameter( | |||||
$key, | |||||
$value); | |||||
} | |||||
} | |||||
} | |||||
$artifact = $build_target->createArtifact( | $artifact = $build_target->createArtifact( | ||||
$viewer, | $viewer, | ||||
$request->getValue('artifactKey'), | $request->getValue('artifactKey'), | ||||
$request->getValue('artifactType'), | $artifact_type, | ||||
$request->getValue('artifactData')); | $artifact_data); | ||||
return array( | return array( | ||||
'data' => $this->returnArtifactList(array($artifact)), | 'data' => $this->returnArtifactList(array($artifact)), | ||||
); | ); | ||||
} | } | ||||
} | } |