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


PHP ApiBase::dieUsage方法代码示例

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


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

示例1: executeAction

 /**
  * Execute the actual module, without any error handling
  */
 protected function executeAction()
 {
     // First add the id to the top element
     if ($this->mRequest->getCheck('requestid')) {
         $this->getResult()->addValue(null, 'requestid', $this->mRequest->getVal('requestid'));
     }
     $params = $this->extractRequestParams();
     $this->mShowVersions = $params['version'];
     $this->mAction = $params['action'];
     if (!is_string($this->mAction)) {
         $this->dieUsage("The API requires a valid action parameter", 'unknown_action');
     }
     // Instantiate the module requested by the user
     $module = new $this->mModules[$this->mAction]($this, $this->mAction);
     if ($module->shouldCheckMaxlag() && isset($params['maxlag'])) {
         // Check for maxlag
         global $wgShowHostnames;
         $maxLag = $params['maxlag'];
         list($host, $lag) = wfGetLB()->getMaxLag();
         if ($lag > $maxLag) {
             header('Retry-After: ' . max(intval($maxLag), 5));
             header('X-Database-Lag: ' . intval($lag));
             // XXX: should we return a 503 HTTP error code like wfMaxlagError() does?
             if ($wgShowHostnames) {
                 ApiBase::dieUsage("Waiting for {$host}: {$lag} seconds lagged", 'maxlag');
             } else {
                 ApiBase::dieUsage("Waiting for a database server: {$lag} seconds lagged", 'maxlag');
             }
             return;
         }
     }
     if (!$this->mInternalMode) {
         // Ignore mustBePosted() for internal calls
         if ($module->mustBePosted() && !$this->mRequest->wasPosted()) {
             $this->dieUsage("The {$this->mAction} module requires a POST request", 'mustbeposted');
         }
         // See if custom printer is used
         $this->mPrinter = $module->getCustomPrinter();
         if (is_null($this->mPrinter)) {
             // Create an appropriate printer
             $this->mPrinter = $this->createPrinterByName($params['format']);
         }
         if ($this->mPrinter->getNeedsRawData()) {
             $this->getResult()->setRawMode();
         }
     }
     // Execute
     $module->profileIn();
     $module->execute();
     wfRunHooks('APIAfterExecute', array(&$module));
     $module->profileOut();
     if (!$this->mInternalMode) {
         // Print result data
         $this->printResult(false);
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:59,代码来源:ApiMain.php

示例2: setupModule

 /**
  * Set up the module for response
  * @return ApiBase The module that will handle this action
  */
 protected function setupModule()
 {
     // Instantiate the module requested by the user
     // RT #1576 5.12.2008 Bartek
     if (class_exists($this->mModules[$this->mAction])) {
         $module = new $this->mModules[$this->mAction]($this, $this->mAction);
         $this->mModule = $module;
     } else {
         ApiBase::dieUsage("Trying to load a nonexistant or undefined classname");
         return;
     }
     $moduleParams = $module->extractRequestParams();
     // Die if token required, but not provided (unless there is a gettoken parameter)
     if (isset($moduleParams['gettoken'])) {
         $gettoken = $moduleParams['gettoken'];
     } else {
         $gettoken = false;
     }
     $salt = $module->getTokenSalt();
     if ($salt !== false && !$gettoken) {
         if (!isset($moduleParams['token'])) {
             $this->dieUsageMsg(array('missingparam', 'token'));
         } else {
             if (!$this->getUser()->matchEditToken($moduleParams['token'], $salt, $this->getRequest())) {
                 $this->dieUsageMsg('sessionfailure');
             }
         }
     }
     return $module;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:34,代码来源:ApiMain.php

示例3: executeAction

 /**
  * Execute the actual module, without any error handling
  */
 protected function executeAction()
 {
     $params = $this->extractRequestParams();
     $this->mShowVersions = $params['version'];
     $this->mAction = $params['action'];
     // Instantiate the module requested by the user
     $module = new $this->mModules[$this->mAction]($this, $this->mAction);
     if ($module->shouldCheckMaxlag() && isset($params['maxlag'])) {
         // Check for maxlag
         global $wgLoadBalancer, $wgShowHostnames;
         $maxLag = $params['maxlag'];
         list($host, $lag) = $wgLoadBalancer->getMaxLag();
         if ($lag > $maxLag) {
             if ($wgShowHostnames) {
                 ApiBase::dieUsage("Waiting for {$host}: {$lag} seconds lagged", 'maxlag');
             } else {
                 ApiBase::dieUsage("Waiting for a database server: {$lag} seconds lagged", 'maxlag');
             }
             return;
         }
     }
     if (!$this->mInternalMode) {
         // Ignore mustBePosted() for internal calls
         if ($module->mustBePosted() && !$this->mRequest->wasPosted()) {
             $this->dieUsage("The {$this->mAction} module requires a POST request", 'mustbeposted');
         }
         // See if custom printer is used
         $this->mPrinter = $module->getCustomPrinter();
         if (is_null($this->mPrinter)) {
             // Create an appropriate printer
             $this->mPrinter = $this->createPrinterByName($params['format']);
         }
         if ($this->mPrinter->getNeedsRawData()) {
             $this->getResult()->setRawMode();
         }
     }
     // Execute
     $module->profileIn();
     $module->execute();
     $module->profileOut();
     if (!$this->mInternalMode) {
         // Print result data
         $this->printResult(false);
     }
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:48,代码来源:ApiMain.php


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