本文整理汇总了PHP中ApiBase::ReturnSuccess方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiBase::ReturnSuccess方法的具体用法?PHP ApiBase::ReturnSuccess怎么用?PHP ApiBase::ReturnSuccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiBase
的用法示例。
在下文中一共展示了ApiBase::ReturnSuccess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dorefreshpackages
public function dorefreshpackages()
{
$results = array();
$i = 0;
try {
$this->_preExecute();
global $loginController;
if (!$loginController->Admin) {
throw new Exception("Unauthorized");
}
$files = scandir(Settings::$PackagesRoot);
$skip = intval(UrlUtils::GetRequestParam("Skip"));
$count = intval(UrlUtils::GetRequestParam("Count"));
$total = sizeof($files);
var_dump($files);
$udb = new UserDb();
$user = $udb->GetByUserId($loginController->UserId);
for ($x = $skip; $x < $total; $x++) {
$file = $files[$x];
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if ($ext == "nupkg") {
$m = $this->_loadNupkg(Path::Combine(Settings::$PackagesRoot, $file), $user->Id);
if (!$m->Success) {
$results[] = $m;
} else {
$i++;
}
}
}
if (sizeof($results) > 0) {
$message = "Refreshed " . $i . " packages over " . sizeof($results) . ".";
ApiBase::ReturnErrorData($results, "", "", sizeof($results), $message, 500);
} else {
$message = "Refreshed " . $i . " packages.";
ApiBase::ReturnSuccess($message);
}
} catch (Exception $ex) {
$message = "Refreshed " . $i . " packages over " . sizeof($results) . ".";
ApiBase::ReturnError($message . "\r\n" . $ex->getMessage(), 500);
}
}
示例2: Update
public function Update()
{
$db = $this->_openDb();
$entity = $this->_buildEntityFromRequest($db);
$keyArray = $this->_buildKeysFromRequest($db);
$allRows = $db->GetAllRows();
$founded = null;
for ($i = 0; $i < sizeof($allRows); $i++) {
if ($this->_isMatch($keyArray, $allRows[$i])) {
$founded = $allRows[$i];
break;
}
}
if ($founded == null) {
ApiBase::ReturnError("Item not found", 404);
}
$this->_verifyUpdate($db, $founded, $entity);
$result = $db->AddRow($entity, true);
if ($result) {
ApiBase::ReturnSuccess($entity);
} else {
ApiBase::ReturnError("Error updating item", 500);
}
}