当前位置: 首页>>代码示例>>PHP>>正文


PHP ApiBase::ReturnError方法代码示例

本文整理汇总了PHP中ApiBase::ReturnError方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiBase::ReturnError方法的具体用法?PHP ApiBase::ReturnError怎么用?PHP ApiBase::ReturnError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiBase的用法示例。


在下文中一共展示了ApiBase::ReturnError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Execute

 public function Execute($method = null)
 {
     if ($method == null) {
         $method = UrlUtils::RequestMethod();
         if (UrlUtils::ExistRequestParam("method")) {
             $method = strtolower(UrlUtils::GetRequestParam("method"));
         }
     }
     $availableMethods = get_class_methods(get_class($this));
     $function = "do" . $method;
     try {
         if (in_array($function, $availableMethods)) {
             $this->{$function}();
         } else {
             ApiBase::ReturnError("Invalid method", 405);
         }
     } catch (Exception $ex) {
         ApiBase::ReturnError($ex->getMessage(), 500);
     }
 }
开发者ID:roly445,项目名称:Php-Nuget-Server,代码行数:20,代码来源:apibase.php

示例2: 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);
     }
 }
开发者ID:roly445,项目名称:Php-Nuget-Server,代码行数:41,代码来源:api_packages.php

示例3: 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);
     }
 }
开发者ID:roly445,项目名称:Php-Nuget-Server,代码行数:24,代码来源:smalltextdbapibase.php


注:本文中的ApiBase::ReturnError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。