本文整理汇总了PHP中Nette\Environment::setMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::setMode方法的具体用法?PHP Environment::setMode怎么用?PHP Environment::setMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Environment
的用法示例。
在下文中一共展示了Environment::setMode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadConfig
//.........这里部分代码省略.........
$key = strtr($key, '-', '\\');
// limited INI chars
if (is_string($value)) {
$context->removeService($key);
$context->addService($key, $value);
} else {
if ($value->factory) {
$context->removeService($key);
$context->addService($key, $value->factory, isset($value->singleton) ? $value->singleton : TRUE, (array) $value->option);
} elseif (isset($this->defaultServices[$key])) {
$context->removeService($key);
$context->addService($key, $this->defaultServices[$key], isset($value->singleton) ? $value->singleton : TRUE, (array) $value->option);
}
if ($value->run) {
$runServices[] = $key;
}
}
}
}
// process ini settings
if (!$config->php) {
// backcompatibility
$config->php = $config->set;
unset($config->set);
}
if ($config->php instanceof Config) {
if (PATH_SEPARATOR !== ';' && isset($config->php->include_path)) {
$config->php->include_path = str_replace(';', PATH_SEPARATOR, $config->php->include_path);
}
foreach (clone $config->php as $key => $value) {
// flatten INI dots
if ($value instanceof Config) {
unset($config->php->{$key});
foreach ($value as $k => $v) {
$config->php->{"{$key}.{$k}"} = $v;
}
}
}
foreach ($config->php as $key => $value) {
$key = strtr($key, '-', '.');
// backcompatibility
if (!is_scalar($value)) {
throw new \InvalidStateException("Configuration value for directive '{$key}' is not scalar.");
}
if ($key === 'date.timezone') {
// PHP bug #47466
date_default_timezone_set($value);
}
if (function_exists('ini_set')) {
ini_set($key, $value);
} else {
switch ($key) {
case 'include_path':
set_include_path($value);
break;
case 'iconv.internal_encoding':
iconv_set_encoding('internal_encoding', $value);
break;
case 'mbstring.internal_encoding':
mb_internal_encoding($value);
break;
case 'date.timezone':
date_default_timezone_set($value);
break;
case 'error_reporting':
error_reporting($value);
break;
case 'ignore_user_abort':
ignore_user_abort($value);
break;
case 'max_execution_time':
set_time_limit($value);
break;
default:
if (ini_get($key) != $value) {
// intentionally ==
throw new \NotSupportedException('Required function ini_set() is disabled.');
}
}
}
}
}
// define constants
if ($config->const instanceof Config) {
foreach ($config->const as $key => $value) {
define($key, $value);
}
}
// set modes
if (isset($config->mode)) {
foreach ($config->mode as $mode => $state) {
Environment::setMode($mode, $state);
}
}
// auto-start services
foreach ($runServices as $name) {
$context->getService($name);
}
return $config;
}