本文整理汇总了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;
}
}
示例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;
}