當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tool::getConfig方法代碼示例

本文整理匯總了PHP中Tool::getConfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tool::getConfig方法的具體用法?PHP Tool::getConfig怎麽用?PHP Tool::getConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tool的用法示例。


在下文中一共展示了Tool::getConfig方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Prepare the object to retrieve access token for
  * specific driver
  */
 public function __construct($provider)
 {
     if (!isset(Tool::getConfig()['oauth'][$provider])) {
         Tool::log('OAuth settings not configured for provider \'' . $provider . '\' in config.php');
         Tool::endWithJson([], 500);
         exit;
     }
     $config = Tool::getConfig()['oauth'][$provider];
     $this->service = $provider;
     if ($provider == 'github') {
         $this->provider = new \League\OAuth2\Client\Provider\Github(['clientId' => $config['clientId'], 'clientSecret' => $config['clientSecret']]);
     } else {
         Tool::endWithJson(["error" => "OAuth Provider " . $provider . " doesn\\'t exist"], 500);
         exit;
     }
 }
開發者ID:glpi-project,項目名稱:plugins,代碼行數:20,代碼來源:OAuthClient.php

示例2: parseRangeHeader

 private function parseRangeHeader()
 {
     global $app;
     $requested = new \stdClass();
     $returned = new \stdClass();
     // Parsing requested header of fallback
     // to a default value
     if ($app->request->headers['x-range'] && preg_match('/^([0-9]+)-([0-9]+)$/', $app->request->headers['x-range'], $start_end)) {
         array_splice($start_end, 0, 1);
         $requested->startIndex = $start_end[0];
         $requested->endIndex = $start_end[1];
     } else {
         if (!isset(Tool::getConfig()['default_number_of_models_per_page'])) {
             $app->error(new \Exception('default_number_of_models_per_page is not set in config.php'));
         }
         $defaultLength = Tool::getConfig()['default_number_of_models_per_page'];
         $requested->startIndex = 0;
         $requested->endIndex = --$defaultLength;
     }
     if ($this->length == 0) {
         $this->responseStatus = 200;
         $this->page = [];
         return;
     } elseif ($requested->startIndex >= $this->length) {
         $this->responseStatus = 400;
         $this->page = ["error" => "Start at unexisting index"];
         return;
     } elseif ($requested->endIndex >= $this->length) {
         $returned->endIndex = $this->length - 1;
     } else {
         $returned->endIndex = $requested->endIndex;
     }
     $returned->startIndex = $requested->startIndex;
     if ($returned->startIndex == 0 && $returned->endIndex == $this->length - 1) {
         $this->responseStatus = 200;
     } else {
         $this->responseStatus = 206;
     }
     $this->currentRange = $returned;
 }
開發者ID:nsautier,項目名稱:plugins,代碼行數:40,代碼來源:PaginatedCollection.php


注:本文中的Tool::getConfig方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。