本文整理匯總了PHP中Criterion::getAPIData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Criterion::getAPIData方法的具體用法?PHP Criterion::getAPIData怎麽用?PHP Criterion::getAPIData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Criterion
的用法示例。
在下文中一共展示了Criterion::getAPIData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getCriterionCreateResponse
public function getCriterionCreateResponse(sfGuardUser $user)
{
/** @var sfWebRequest $request */
$request = $this->getRequest();
$decision = DecisionTable::getInstance()->getDecisionForUser($user, $request->getParameter('decision_id'));
if (is_object($decision)) {
$criterion = new Criterion();
$criterion->Decision = $decision;
$criterion->name = $request->getParameter('name', 'New criterion');
$criterion->description = $request->getParameter('description', '');
$criterion->variable_type = $request->getParameter('type', 'Benefit');
$criterion->measurement = $request->getParameter('measure', 'five point scale');
try {
$criterion->save();
$result = array('status' => 'success', 'result' => $criterion->getAPIData());
} catch (sfException $ex) {
$result = array('status' => 'error', 'error' => $ex->getMessage());
}
} else {
$result = array('status' => 'error', 'error' => sprintf('Project with id %d does not exist', $request->getParameter('decision_id')));
}
return $result;
}