本文整理汇总了PHP中Config::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::get方法的具体用法?PHP Config::get怎么用?PHP Config::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDefault
/**
* Try to retrieve a default setting from a config fallback.
*
* @param string $key
* @param mixed $default
*
* @return mixed config setting or default when not found
*/
protected function getDefault($key, $default)
{
if (!$this->fallback) {
return $default;
}
return $this->fallback->get($key, $default);
}
示例2: CreateOnePlanetRecord
/**
* 2Moons
* Copyright (C) 2012 Jan Kröpke
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package 2Moons
* @author Jan Kröpke <info@2moons.cc>
* @copyright 2012 Jan Kröpke <info@2moons.cc>
* @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
* @version 1.7.3 (2013-05-19)
* @info $Id: CreateOnePlanetRecord.php 2640 2013-03-23 19:23:26Z slaver7 $
* @link http://2moons.cc/
*/
function CreateOnePlanetRecord($Galaxy, $System, $Position, $Universe, $PlanetOwnerID, $PlanetName, $HomeWorld = false, $AuthLevel = 0, $Iron, $Gold, $Crystal, $Elyrium, $iPlanetCount)
{
global $LNG;
$CONF = Config::getAll(NULL, $Universe);
if (Config::get('max_galaxy') < $Galaxy || 1 > $Galaxy) {
throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position);
}
if (Config::get('max_system') < $System || 1 > $System) {
throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position);
}
if (Config::get('max_planets') < $Position || 1 > $Position) {
throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position);
}
if (CheckPlanetIfExist($Galaxy, $System, $Position, $Universe)) {
return false;
}
$tp = 0;
if ($iPlanetCount >= 3) {
$tp = 1;
}
$FieldFactor = Config::get('planet_factor');
require 'includes/PlanetData.php';
$Pos = ceil($Position / (Config::get('max_planets') / count($PlanetData)));
$TMax = $PlanetData[$Pos]['temp'];
$TMin = $TMax - 40;
$Fields = $PlanetData[$Pos]['fields'] * Config::get('planet_factor');
$Types = $PlanetData[$Pos]['image'];
$Name = !empty($PlanetName) ? $GLOBALS['DATABASE']->sql_escape($PlanetName) : $LNG['type_planet'][1];
$GLOBALS['DATABASE']->query("INSERT INTO " . PLANETS . " SET\n\t\t\t\tname = '" . $Name . "',\n\t\t\t\tuniverse = " . $Universe . ",\n\t\t\t\tid_owner = " . $PlanetOwnerID . ",\n\t\t\t\tgalaxy = " . $Galaxy . ",\n\t\t\t\tsystem = " . $System . ",\n\t\t\t\tplanet = " . $Position . ",\n\t\t\t\tlast_update = " . TIMESTAMP . ",\n\t\t\t\tplanet_type = '1',\n\t\t\t\tcolo_metal = " . $Iron . ",\n\t\t\t\tcolo_crystal = " . $Gold . ",\n\t\t\t\tcolo_deut = " . $Crystal . ",\n\t\t\t\tcolo_elyrium = " . $Elyrium . ",\n\t\t\t\tteleport_portal = " . $tp . ",\n\t\t\t\timage = '" . $Types . "',\n\t\t\t\tdiameter = " . floor(1000 * sqrt($Fields)) . ",\n\t\t\t\tfield_max = " . ($HomeWorld ? Config::get('initial_fields') : floor($Fields)) . ",\n\t\t\t\ttemp_min = " . $TMin . ",\n\t\t\t\ttemp_max = " . $TMax . ",\n\t\t\t\tmetal = " . Config::get('metal_start') . ",\n\t\t\t\tmetal_perhour = " . Config::get('metal_basic_income') . ",\n\t\t\t\tcrystal = " . Config::get('crystal_start') . ",\n\t\t\t\tcrystal_perhour = " . Config::get('crystal_basic_income') . ",\n\t\t\t\tdeuterium = " . Config::get('deuterium_start') . ",\n\t\t\t\tdeuterium_perhour = " . Config::get('deuterium_basic_income') . ",\n\t\t\t\telyrium = " . Config::get('deuterium_start') . ",\n\t\t\t\telyrium_perhour = " . Config::get('deuterium_basic_income') . ";");
return $GLOBALS['DATABASE']->GetInsertID();
}
示例3: applyDefaultParameters
/**
* @param array $params
* @param Config $mainConfig
* @return array
*/
public static function applyDefaultParameters(array $params, Config $mainConfig)
{
$logger = LoggerFactory::getInstance('Mime');
$params += ['typeFile' => $mainConfig->get('MimeTypeFile'), 'infoFile' => $mainConfig->get('MimeInfoFile'), 'xmlTypes' => $mainConfig->get('XMLMimeTypes'), 'guessCallback' => function ($mimeAnalyzer, &$head, &$tail, $file, &$mime) use($logger) {
// Also test DjVu
$deja = new DjVuImage($file);
if ($deja->isValid()) {
$logger->info(__METHOD__ . ": detected {$file} as image/vnd.djvu\n");
$mime = 'image/vnd.djvu';
return;
}
// Some strings by reference for performance - assuming well-behaved hooks
Hooks::run('MimeMagicGuessFromContent', [$mimeAnalyzer, &$head, &$tail, $file, &$mime]);
}, 'extCallback' => function ($mimeAnalyzer, $ext, &$mime) {
// Media handling extensions can improve the MIME detected
Hooks::run('MimeMagicImproveFromExtension', [$mimeAnalyzer, $ext, &$mime]);
}, 'initCallback' => function ($mimeAnalyzer) {
// Allow media handling extensions adding MIME-types and MIME-info
Hooks::run('MimeMagicInit', [$mimeAnalyzer]);
}, 'logger' => $logger];
if ($params['infoFile'] === 'includes/mime.info') {
$params['infoFile'] = __DIR__ . "/libs/mime/mime.info";
}
if ($params['typeFile'] === 'includes/mime.types') {
$params['typeFile'] = __DIR__ . "/libs/mime/mime.types";
}
$detectorCmd = $mainConfig->get('MimeDetectorCommand');
if ($detectorCmd) {
$params['detectCallback'] = function ($file) use($detectorCmd) {
return wfShellExec("{$detectorCmd} " . wfEscapeShellArg($file));
};
}
return $params;
}
示例4: getKafkaProducer
/**
* Get the producer object from kafka-php.
* @return Produce
*/
protected function getKafkaProducer()
{
if (!$this->producer) {
$this->producer = Produce::getInstance(null, null, $this->config->get('KafkaEventHost'));
}
return $this->producer;
}
示例5: getAll
/**
* Gets all user limited with page and limit
*
* @param int $page
* @param into $limit
* @return object
*/
public function getAll($page = 1, $limit = 40)
{
$users = $this->dc->qb()->select('*')->from($this->dc->p($this->config->get('foolz/foolframe', 'foolauth', 'table_name')), 't')->setMaxResults($limit)->setFirstResult($page * $limit - $limit)->execute()->fetchAll();
$users = User::forge($this->getContext(), $users);
$count = $this->dc->qb()->select('COUNT(*) as count')->from($this->dc->p($this->config->get('foolz/foolframe', 'foolauth', 'table_name')), 't')->execute()->fetch();
return ['result' => $users, 'count' => $count['count']];
}
示例6: __construct
/**
* @param array $settings
* @param string $environment
*/
public function __construct(array $settings = [], $environment = self::ENV_DEVELOPMENT)
{
parent::__construct();
if (!defined('INFUSE_BASE_DIR')) {
die('INFUSE_BASE_DIR has not been defined!');
}
/* Load Configuration */
$configWithDirs = ['dirs' => ['app' => INFUSE_BASE_DIR . '/app', 'assets' => INFUSE_BASE_DIR . '/assets', 'public' => INFUSE_BASE_DIR . '/public', 'temp' => INFUSE_BASE_DIR . '/temp', 'views' => INFUSE_BASE_DIR . '/views']];
$settings = array_replace_recursive(static::$baseConfig, $configWithDirs, $settings);
$config = new Config($settings);
$this['config'] = $config;
$this['environment'] = $environment;
/* Base URL */
$this['base_url'] = function () use($config) {
$url = ($config->get('app.ssl') ? 'https' : 'http') . '://';
$url .= $config->get('app.hostname');
$port = $config->get('app.port');
$url .= (!in_array($port, [0, 80, 443]) ? ':' . $port : '') . '/';
return $url;
};
/* Services */
foreach ($config->get('services') as $name => $class) {
$this[$name] = new $class($this);
}
// set the last created app instance
self::$default = $this;
}
示例7: init
/**
* Initialize the internal static variables using the global variables
*
* @param Config $config Configuration object to load data from
*/
public function init(Config $config)
{
foreach ($config->get('PasswordConfig') as $type => $options) {
$this->register($type, $options);
}
$this->setDefaultType($config->get('PasswordDefault'));
}
示例8: init
public static function init()
{
if (self::$hasinit) {
return false;
}
// Load configuration.
self::$config = new Config('realms.ini');
if (!self::$config->get('general', 'service_requests')) {
// Service unavaliable. :(
http_response_code(503);
// 503 Service Unavaliable.
echo 'service unavaliable';
exit;
// terminate here.
}
// Load request registry
self::$requestRegistry = new RequestRegistry();
// create request registry instance
// Dynamically load request handlers.
$handler_files = scandir('inc/Requests');
foreach ($handler_files as $handler_file) {
if ($handler_file == '.' || $handler_file == '..') {
continue;
}
// skip ghost files
// Load PHP file
require 'inc/Requests/' . $handler_file;
// Register handler
$classname = pathinfo($handler_file, PATHINFO_FILENAME);
self::$requestRegistry->register(new $classname());
}
// Realms init finish.
self::$hasinit = true;
return true;
}
示例9: testGet3
/**
* Test root/production/host1 level config
*
* @covers Phossa\Config\Reference\Config::get()
*/
public function testGet3()
{
$this->object = new Config(__DIR__ . '/testData/', 'production/host1');
$this->assertEquals('bingo', $this->object->get('db.auth.user'));
$this->assertEquals('nopass', $this->object->get('db.auth.pass'));
$this->assertEquals('dbhost', $this->object->get('db.auth.host'));
$this->assertEquals(3506, $this->object->get('db.auth.port'));
}
示例10: testFromArray
public function testFromArray()
{
$expected = array('nome' => 'andre', 'sobrenome' => 'nascimento');
$config = new Config();
$config->fromArray($expected);
$this->AssertEquals($expected['nome'], $config->get('nome'));
$this->AssertEquals($expected['sobrenome'], $config->get('sobrenome'));
}
示例11: testSetterMultidimensionOverwritesNestedValues
public function testSetterMultidimensionOverwritesNestedValues()
{
$c = new Config(array('config' => array('deploy' => array('release_dir' => '/var/www'))));
$this->assertEquals('/var/www', $c->get('config.deploy.release_dir'));
$c->set('config.deploy.release_dir', '/var/www');
$c->set('config.deploy.release_dir', '/var/www');
$this->assertEquals('/var/www', $c->get('config.deploy.release_dir'));
}
示例12: httpsBool
/**
* HTTPS Bool
*
* Gets HTTPS status in bool form
*
* @param Config $config
* @return bool
* @throws Exception
*/
public static function httpsBool(Config $config)
{
if ($config->get('server', 'protocol') === 'https://') {
return true;
} elseif ($config->get('server', 'protocol') === 'http://') {
return false;
}
throw new Exception("Protocol is not known. " . $config->get('server', 'protocol') === 'https://');
}
示例13: get
/**
* @param $userID
* @param $serverID
* @return int|string
*/
public function get($userID, $serverID)
{
foreach ($this->config->get("admins", "permissions") as $adminID) {
if ($adminID == $userID) {
return 2;
}
}
return $this->db->queryField("SELECT permission FROM permissions WHERE userID = :userID AND serverID = :serverID", "permission", [":userID" => $userID, ":serverID" => $serverID]);
}
示例14: testLoadConfig
public function testLoadConfig()
{
$config = new Config(__DIR__, "/config.conf");
$teste = $config->get('teste');
$this->assertTrue(is_array($teste));
$this->assertCount(2, $teste);
$this->assertEquals('Ecomz\\Common', $teste['nome']);
$this->assertEquals('Ivo Nascimento', $teste['author']);
$this->assertEquals('qualquer data', $config->get('nosectiondata'));
}
示例15: __construct
public function __construct()
{
$conf = new Config();
$this->base_url = $conf->get('app.base_url');
$this->_module = $conf->get('app.default_module');
$this->_page = $conf->get('app.default_page');
$this->_page = $conf->get('app.default_act');
$this->_params = $conf->get('app.default_params');
$conf->close();
}