Differential D21872 Diff 52175 src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php
Show All 24 Lines | final class DifferentialSetDiffPropertyConduitAPIMethod | ||||
protected function defineErrorTypes() { | protected function defineErrorTypes() { | ||||
return array( | return array( | ||||
'ERR_NOT_FOUND' => pht('Diff was not found.'), | 'ERR_NOT_FOUND' => pht('Diff was not found.'), | ||||
); | ); | ||||
} | } | ||||
protected function execute(ConduitAPIRequest $request) { | protected function execute(ConduitAPIRequest $request) { | ||||
$data = $request->getValue('data'); | |||||
if ($data === null || !strlen($data)) { | |||||
throw new Exception(pht('Field "data" must be non-empty.')); | |||||
} | |||||
$diff_id = $request->getValue('diff_id'); | $diff_id = $request->getValue('diff_id'); | ||||
if ($diff_id === null) { | |||||
throw new Exception(pht('Field "diff_id" must be non-null.')); | |||||
} | |||||
$name = $request->getValue('name'); | $name = $request->getValue('name'); | ||||
$data = json_decode($request->getValue('data'), true); | if ($name === null || !strlen($name)) { | ||||
throw new Exception(pht('Field "name" must be non-empty.')); | |||||
} | |||||
$data = json_decode($data, true); | |||||
self::updateDiffProperty($diff_id, $name, $data); | self::updateDiffProperty($diff_id, $name, $data); | ||||
} | } | ||||
private static function updateDiffProperty($diff_id, $name, $data) { | private static function updateDiffProperty($diff_id, $name, $data) { | ||||
$property = id(new DifferentialDiffProperty())->loadOneWhere( | $property = id(new DifferentialDiffProperty())->loadOneWhere( | ||||
'diffID = %d AND name = %s', | 'diffID = %d AND name = %s', | ||||
$diff_id, | $diff_id, | ||||
Show All 12 Lines |