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


PHP Request::isApiRequest方法代码示例

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


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

示例1: test_isApiRequest_shouldDetectIfItIsApiRequestOrNot

 public function test_isApiRequest_shouldDetectIfItIsApiRequestOrNot()
 {
     $this->assertFalse(Request::isApiRequest(array()));
     $this->assertFalse(Request::isApiRequest(array('module' => '', 'method' => '')));
     $this->assertFalse(Request::isApiRequest(array('module' => 'API')));
     // no method
     $this->assertFalse(Request::isApiRequest(array('module' => 'CoreHome', 'method' => 'index.test')));
     // not api
     $this->assertFalse(Request::isApiRequest(array('module' => 'API', 'method' => 'testmethod')));
     // no valid action
     $this->assertTrue(Request::isApiRequest(array('module' => 'API', 'method' => 'test.method')));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:12,代码来源:RequestTest.php

示例2: displayDbConnectionMessage

 public function displayDbConnectionMessage($exception = null)
 {
     Common::sendResponseCode(500);
     $errorMessage = $exception->getMessage();
     if (Request::isApiRequest($_GET)) {
         $ex = new DatabaseConnectionFailedException($errorMessage);
         throw $ex;
     }
     $view = new PiwikView("@Installation/cannotConnectToDb");
     $view->exceptionMessage = $errorMessage;
     $ex = new DatabaseConnectionFailedException($view->render());
     $ex->setIsHtmlMessage();
     throw $ex;
 }
开发者ID:cemo,项目名称:piwik,代码行数:14,代码来源:Installation.php

示例3: getErrorResponse

 private static function getErrorResponse(Exception $ex)
 {
     $debugTrace = $ex->getTraceAsString();
     $message = $ex->getMessage();
     $isHtmlMessage = method_exists($ex, 'isHtmlMessage') && $ex->isHtmlMessage();
     if (!$isHtmlMessage && Request::isApiRequest($_GET)) {
         $outputFormat = strtolower(Common::getRequestVar('format', 'xml', 'string', $_GET + $_POST));
         $response = new ResponseBuilder($outputFormat);
         return $response->getResponseException($ex);
     } elseif (!$isHtmlMessage) {
         $message = Common::sanitizeInputValue($message);
     }
     $logo = new CustomLogo();
     $logoHeaderUrl = false;
     $logoFaviconUrl = false;
     try {
         $logoHeaderUrl = $logo->getHeaderLogoUrl();
         $logoFaviconUrl = $logo->getPathUserFavicon();
     } catch (Exception $ex) {
         try {
             Log::debug($ex);
         } catch (\Exception $otherEx) {
             // DI container may not be setup at this point
         }
     }
     $result = Piwik_GetErrorMessagePage($message, $debugTrace, true, true, $logoHeaderUrl, $logoFaviconUrl);
     try {
         /**
          * Triggered before a Piwik error page is displayed to the user.
          *
          * This event can be used to modify the content of the error page that is displayed when
          * an exception is caught.
          *
          * @param string &$result The HTML of the error page.
          * @param Exception $ex The Exception displayed in the error page.
          */
         Piwik::postEvent('FrontController.modifyErrorPage', array(&$result, $ex));
     } catch (ContainerDoesNotExistException $ex) {
         // this can happen when an error occurs before the Piwik environment is created
     }
     return $result;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:42,代码来源:ExceptionHandler.php


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