本文整理汇总了PHP中lmb_env_get函数的典型用法代码示例。如果您正苦于以下问题:PHP lmb_env_get函数的具体用法?PHP lmb_env_get怎么用?PHP lmb_env_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lmb_env_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConf
function getConf($name)
{
$name = $this->_normalizeConfName($name);
if (isset($this->confs[$name])) {
return $this->confs[$name];
}
$ext = substr($name, strpos($name, '.'));
if ($ext == '.ini') {
$file = $this->_locateConfFiles($name);
if (lmb_env_has('LIMB_VAR_DIR')) {
$this->confs[$name] = new lmbCachedIni($file, lmb_env_get('LIMB_VAR_DIR') . '/ini/');
} else {
$this->confs[$name] = new lmbIni($file);
}
} elseif ($ext == '.yml') {
$file = $this->_locateConfFiles($name);
$this->confs[$name] = $this->parseYamlFile(lmbFs::normalizePath($file));
} elseif ($ext == '.conf.php') {
$file = $this->_locateConfFiles($name);
if (!count($file)) {
throw new lmbFileNotFoundException($name);
}
$this->confs[$name] = new lmbConf(lmbFs::normalizePath($file));
} else {
throw new lmbException("'{$ext}' type configuration is not supported!");
}
return $this->confs[$name];
}
示例2: getRootDir
function getRootDir()
{
if (!($root_dir = lmb_env_get('LIMB_DOCUMENT_ROOT', false))) {
throw new lmbMacroException('Not set require env LIMB_DOCUMENT_ROOT!');
}
return $root_dir;
}
示例3: testRequirePackageClass
function testRequirePackageClass()
{
$package_name = 'require_package_source';
$package_source_dir = lmb_env_get('LIMB_PACKAGES_DIR') . '/' . $package_name . '/src/';
$package_class = 'SourceFileForTests';
$this->createPackageMainFile($package_name, lmb_env_get('LIMB_PACKAGES_DIR'));
if (!file_exists($package_source_dir)) {
mkdir($package_source_dir);
}
$source_file_content = <<<EOD
<?php
class {$package_class} {
static function increase() {
lmbPackagesFunctionsTest::\$counter++;
}
}
EOD;
file_put_contents($package_source_dir . '/' . $package_class . '.class.php', $source_file_content);
$this->assertIdentical(0, lmbPackagesFunctionsTest::$counter);
lmb_package_require($package_name);
$this->assertIdentical(1, lmbPackagesFunctionsTest::$counter);
lmb_require_package_class($package_name, 'SourceFileForTests');
call_user_func(array($package_class, 'increase'));
$this->assertIdentical(2, lmbPackagesFunctionsTest::$counter);
}
示例4: createLocaleObject
function createLocaleObject($locale)
{
$file = $this->toolkit->findFileByAlias($locale . '.ini', lmb_env_get('LIMB_LOCALE_INCLUDE_PATH'), 'i18n_locale');
if (lmb_env_has('LIMB_VAR_DIR')) {
return new lmbLocale($locale, new lmbCachedIni($file, lmb_env_get('LIMB_VAR_DIR') . '/locale/'));
} else {
return new lmbLocale($locale, new lmbIni($file));
}
}
示例5: __construct
function __construct()
{
parent::__construct();
$items = explode(';', lmb_env_get('LIMB_SUPPORTED_VIEW_TYPES'));
foreach ($items as $item) {
list($ext, $class) = explode('=', $item);
$this->view_types[$ext] = $class;
}
}
示例6: getLogDSNes
function getLogDSNes()
{
$default_dsn = 'file://' . lmbFs::normalizePath(lmb_env_get('LIMB_VAR_DIR') . '/log/error.log');
if (!$this->toolkit->hasConf('common')) {
return array($default_dsn);
}
$conf = $this->toolkit->getConf('common');
if (!isset($conf['logs'])) {
return array($default_dsn);
}
return $conf['logs'];
}
示例7: lmb_package_require
/**
* @package core
* @version $Id$
*/
function lmb_package_require($name, $packages_dir = '')
{
if (!$packages_dir) {
$packages_dir = lmb_env_get('LIMB_PACKAGES_DIR');
}
$main_file_path = $packages_dir . $name . '/common.inc.php';
try {
lmb_require($packages_dir . $name . '/common.inc.php');
} catch (lmbPHPFileNotFoundException $e) {
lmb_require('limb/core/src/exception/lmbNoSuchPackageException.class.php');
throw new lmbNoSuchPackageException("Package '{$name}' not found", array('name' => $name, 'dir' => $packages_dir, 'main_file' => $main_file_path));
}
}
示例8: __construct
function __construct($config = array())
{
$conf = lmbToolkit::instance()->getConf('mail');
$this->use_phpmail = $conf['use_phpmail'];
$this->smtp_host = $conf['smtp_host'];
$this->smtp_port = $conf['smtp_port'];
$this->smtp_auth = $conf['smtp_auth'];
$this->smtp_user = $conf['smtp_user'];
$this->smtp_password = $conf['smtp_password'];
$this->setConfig($config);
$php_mailer_version = lmb_env_get('PHPMAILER_VERSION_NAME', 'phpmailer-5.1');
include_once 'limb/mail/lib/' . $php_mailer_version . '/class.phpmailer.php';
}
示例9: testGetFilesLocator_CacheConditions
function testGetFilesLocator_CacheConditions()
{
$old_mode = lmb_env_get('LIMB_APP_MODE');
$old_var_dir = lmb_env_get('LIMB_VAR_DIR');
lmb_env_set('LIMB_APP_MODE', 'devel');
lmb_env_remove('LIMB_VAR_DIR');
$this->assertIsA($this->tools->getFileLocator('foo', 'locator1'), 'lmbFileLocator');
lmb_env_set('LIMB_VAR_DIR', $old_var_dir);
$this->assertIsA($this->tools->getFileLocator('foo', 'locator2'), 'lmbFileLocator');
lmb_env_set('LIMB_APP_MODE', 'production');
$this->assertIsA($this->tools->getFileLocator('foo', 'locator3'), 'lmbCachingFileLocator');
lmb_env_set('LIMB_APP_MODE', $old_mode);
}
示例10: testDispatchWithOffset
function testDispatchWithOffset()
{
$old_offset = lmb_env_get('LIMB_HTTP_OFFSET_PATH');
$config_array = array(array('path' => ':controller/:action'));
$routes = new lmbRoutes($config_array);
$this->toolkit->setRoutes($routes);
$dispatcher = new lmbRoutesRequestDispatcher();
lmb_env_set('LIMB_HTTP_OFFSET_PATH', 'app');
$this->request->getUri()->reset('http://example.com/app/news/admin_display');
$result = $dispatcher->dispatch($this->request);
$this->assertEqual($result['controller'], 'news');
$this->assertEqual($result['action'], 'admin_display');
lmb_env_set('LIMB_HTTP_OFFSET_PATH', $old_offset);
}
示例11: testOnceRender
function testOnceRender()
{
$root = lmb_env_get('LIMB_VAR_DIR') . '/www/';
lmb_env_set('LIMB_DOCUMENT_ROOT', $root);
lmbFs::safeWrite($root . 'style/main.css', 'body {background-url: url("../images/one.jpg");}');
lmbFs::safeWrite($root . 'images/one.jpg', 'simple content');
$template = '{{css_compiled src="style/main.css" dir="media/css" /}}';
$page = $this->_createMacroTemplate($template, 'tpl.html');
$content = $page->render();
$src = $this->toolkit->addVersionToUrl('media/css/style-main.css');
$this->assertEqual('<link rel="stylesheet" type="text/css" href="' . $src . '" />', $content);
$compiled_file = $root . 'media/css/style-main.css';
$src = $this->toolkit->addVersionToUrl('images/one.jpg');
$this->assertEqual('body {background-url: url(' . $src . ');}', file_get_contents($compiled_file));
}
示例12: getTmpDir
static function getTmpDir()
{
if (lmb_env_has('LIMB_VAR_DIR')) {
return lmb_env_get('LIMB_VAR_DIR');
}
if ($path = session_save_path()) {
if (($pos = strpos($path, ';')) !== false) {
$path = substr($path, $pos + 1);
}
return $path;
}
if ($tmp = getenv('TMP') || ($tmp = getenv('TEMP') || ($tmp = getenv('TMPDIR')))) {
return $tmp;
}
//gracefull falback?
return '/tmp';
}
示例13: testGzipStatic
function testGzipStatic()
{
if (!function_exists('gzencode')) {
return print "Skip: function gzencode not exists.\n";
}
lmb_env_set('LIMB_DOCUMENT_ROOT', lmb_env_get('LIMB_VAR_DIR') . '/www/');
lmbFs::safeWrite(lmb_env_get('LIMB_VAR_DIR') . '/www/one.js', 'var window = {};');
$doc_root = lmb_env_get('LIMB_DOCUMENT_ROOT');
$template = '{{file:version src="one.js" gzip_static_dir="media/var/gz" gzip_level="9" }}';
$page = $this->_createMacroTemplate($template, 'tpl.html');
$content = $page->render();
$file = 'media/var/gz/one.js';
$this->assertEqual($content, $this->toolkit->addVersionToUrl($file, false));
$this->assertEqual('var window = {};', file_get_contents($doc_root . $file));
$gz_file = $doc_root . $file . '.gz';
$this->assertTrue(file_exists($gz_file));
$this->assertEqual(gzencode('var window = {};', 9, FORCE_DEFLATE), file_get_contents($gz_file));
}
示例14: lmb_tests_init_db_dsn
function lmb_tests_init_db_dsn()
{
lmb_env_set('LIMB_CACHE_DB_META_IN_FILE', false);
if (lmbToolkit::instance()->isDefaultDbDSNAvailable()) {
$dsn = lmbToolkit::instance()->getDefaultDbDSN();
static $reported_about;
if (is_null($reported_about) || $reported_about != $dsn) {
$pass = $dsn->_getUri()->getPassword();
$masked_dsn = str_replace($pass, str_pad('*', strlen($pass), '*'), $dsn->toString());
echo "INFO: Using database '{$masked_dsn}'\n";
$reported_about = $dsn;
}
} else {
$default_value = 'sqlite://localhost/' . lmb_var_dir() . '/sqlite_tests.db';
$dsn = lmb_env_get('LIMB_TEST_DB_DSN', $default_value);
lmbToolkit::instance()->setDefaultDbDSN($dsn);
echo "INFO: Using default test database '{$dsn}'\n";
}
}
示例15: testNotFoundFile
function testNotFoundFile()
{
lmb_env_set('LIMB_DOCUMENT_ROOT', lmb_env_get('LIMB_VAR_DIR'));
$template = '{{js:require_once src="js/main.js" }}';
$page = $this->_createMacroTemplate($template, 'tpl.html');
try {
$page->render();
$this->assertTrue(false);
} catch (lmbException $e) {
$this->assertTrue(true);
}
$template = '{{js:require_once src="js/main.js" safe="true" }}';
$page = $this->_createMacroTemplate($template, 'tpl.html');
try {
$page->render();
$this->assertTrue(true);
} catch (lmbException $e) {
$this->assertTrue(false);
}
}