Changeset View
Changeset View
Standalone View
Standalone View
src/applications/herald/controller/HeraldRuleController.php
Show First 20 Lines • Show All 252 Lines • ▼ Show 20 Lines | private function saveRule(HeraldAdapter $adapter, $rule, $request) { | ||||
$e_name = true; | $e_name = true; | ||||
$errors = array(); | $errors = array(); | ||||
if (!strlen($rule->getName())) { | if (!strlen($rule->getName())) { | ||||
$e_name = pht('Required'); | $e_name = pht('Required'); | ||||
$errors[] = pht('Rule must have a name.'); | $errors[] = pht('Rule must have a name.'); | ||||
} | } | ||||
$data = json_decode($request->getStr('rule'), true); | $data = null; | ||||
try { | |||||
$data = phutil_json_decode($request->getStr('rule')); | |||||
} catch (PhutilJSONParserException $ex) { | |||||
throw new PhutilProxyException( | |||||
pht('Failed to decode rule data.'), | |||||
$ex); | |||||
} | |||||
if (!is_array($data) || | if (!is_array($data) || | ||||
!$data['conditions'] || | !$data['conditions'] || | ||||
!$data['actions']) { | !$data['actions']) { | ||||
throw new Exception('Failed to decode rule data.'); | throw new Exception('Failed to decode rule data.'); | ||||
} | } | ||||
$conditions = array(); | $conditions = array(); | ||||
foreach ($data['conditions'] as $condition) { | foreach ($data['conditions'] as $condition) { | ||||
▲ Show 20 Lines • Show All 406 Lines • Show Last 20 Lines |