本文整理汇总了PHP中Environment::getConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::getConfig方法的具体用法?PHP Environment::getConfig怎么用?PHP Environment::getConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::getConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constractor creates connection and checks/creates tables stucture
*/
public function __construct()
{
$dibiConfig = dibi::getConnection()->getConfig();
$dbname = isset($dibiConfig['dbname']) ? $dibiConfig['dbname'] : $dibiConfig['database'];
$config = array('driver' => 'sqlite', 'profiler' => Environment::getConfig('perform')->storage_profiler, 'database' => realpath(Environment::getConfig('perform')->modelCache) . '/' . $dbname . '-storage.sdb');
parent::__construct($config, 'storage');
if (!$this->getDatabaseInfo()->hasTable('fields')) {
$this->query('CREATE TABLE [fields] ([id] INTEGER NOT NULL PRIMARY KEY,
[name] VARCHAR(100) NOT NULL, [table] VARCHAR(50) NOT NULL,
[hash] VARCHAR(32) NOT NULL, [type] VARCHAR(50));
CREATE UNIQUE INDEX [fields_idx] on [fields] ( [name], [table]);');
}
if (!$this->getDatabaseInfo()->hasTable('tables')) {
$this->query('CREATE TABLE [tables] ( [id] INTEGER NOT NULL PRIMARY KEY,
[name] VARCHAR(100) NOT NULL UNIQUE, [hash] VARCHAR(32) NOT NULL);');
}
if (!$this->getDatabaseInfo()->hasTable('views')) {
$this->query('CREATE TABLE [views] ( [id] INTEGER NOT NULL PRIMARY KEY,
[name] VARCHAR(100) NOT NULL UNIQUE, [hash] VARCHAR(32) NOT NULL);');
}
if (!$this->getDatabaseInfo()->hasTable('indexes')) {
$this->query('CREATE TABLE [indexes] ([id] INTEGER NOT NULL PRIMARY KEY,
[name] VARCHAR(100) NOT NULL, [table] VARCHAR(50) NOT NULL,
[hash] VARCHAR(32) NOT NULL, [unique] BOOLEAN);
CREATE UNIQUE INDEX [indexes_idx] on [indexes] ( [name], [table]);');
}
}
示例2: __construct
public function __construct()
{
$this->config['useAcl'] = Environment::getConfig('global')->useAcl;
// init hasher
$this->config['hasher'] = Environment::getConfig('hasher');
$this->hasher = BaseHasher::create($this->config['hasher']->type, $this->config['hasher']);
}
示例3: sendPassFormSubmitted
public function sendPassFormSubmitted($form)
{
$values = $form->getValues();
$user = $this->model->findByEmail($values['email']);
if (!$user->id) {
// $this->flashMessage('Účet so zadaným e-mailom neexistuje', self::FLASH_MESSAGE_ERROR);
$this->flashMessage('Provided email does not exist in the system', self::FLASH_MESSAGE_ERROR);
$this->redirect('this');
} else {
$token = $this->model->allowTemporaryLogin($user->id, $values['email'], $this->tempLoginTokenExpiration);
// send email with url for temporary login
try {
$email_template = $this->createTemplate();
$email_template->setFile(__DIR__ . '/../templates/email.phtml');
$email_template->completeName = $user->completeName;
$email_template->tempLoginUri = $this->link('//tempLogin', array('tempLoginToken' => $token));
$mail = new Mail();
$mail->setFrom(Environment::getConfig("contact")->forgottenPassEmail);
$mail->addTo($values['email']);
$mail->setSubject('Password Assistance');
$mail->setHtmlBody($email_template);
$mail->send();
} catch (DibiDriverException $e) {
$this->flashMessage(OPERATION_FAILED, self::FLASH_MESSAGE_ERROR);
$this->redirect('this');
} catch (InvalidStateException $e) {
// $this->flashMessage('Email sa nepodarilo odoslať, skúste znova o pár sekúnd', self::FLASH_MESSAGE_ERROR);
$this->flashMessage('Email could NOT be sent. Please try again in a moment', self::FLASH_MESSAGE_ERROR);
$this->redirect('this');
}
// $this->flashMessage('Na zadaný e-mail boli odoslané prihlasovacie údaje', self::FLASH_MESSAGE_SUCCESS);
$this->flashMessage('E-mail with detailed information has been sent to ' . $values['email'], self::FLASH_MESSAGE_SUCCESS);
$this->redirect('this');
}
}
示例4: convert
/**
* Convert
*
* Loads HTML and passes to getMarkdown()
*
* @param $html
*
* @return string The Markdown version of the html
*/
public function convert($html)
{
if ($html === '' && $this->environment->getConfig()->getOption('suppress_errors')) {
return '';
}
$document = $this->createDOMDocument($html);
// Work on the entire DOM tree (including head and body)
if (!($root = $document->getElementsByTagName('html')->item(0))) {
throw new \InvalidArgumentException('Invalid HTML was provided');
}
$rootElement = new Element($root);
$this->convertChildren($rootElement);
// Store the now-modified DOMDocument as a string
$markdown = $document->saveHTML();
$markdown = $this->sanitize($markdown);
return $markdown;
}
示例5: __construct
public function __construct()
{
//db::connect();
$config = Environment::getConfig();
$this->prefix = '';
$this->startup();
$this->__after_startup();
}
示例6: __construct
/**
* Constructor
*/
public function __construct()
{
/* check if modelCacheDir valid */
$this->modelCacheDir = realpath(Environment::getConfig('perform')->modelCache);
if (!file_exists($this->modelCacheDir) and !mkdir($this->modelCacheDir, 0777, true)) {
throw new Exception("Unable to create model cache directory '{$this->modelCacheDir}'.");
}
if (!is_writable($this->modelCacheDir)) {
throw new Exception("Model cache directory '{$this->modelCacheDir}' is not writable.");
}
}
示例7: connect
public static function connect($settings = array(), $connection_name = null)
{
$config = Environment::getConfig();
foreach ($config['database'] as $connection_name => $settings) {
try {
dibi::connect($settings, $connection_name);
if ($settings['profiler'] == true) {
dibi::getProfiler()->setFile(APP_DIR . '/log/db.txt');
}
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
}
}
示例8: initialize
public static function initialize()
{
$conf = Environment::getConfig('database');
$connection = dibi::connect($conf[$conf->engine]);
if ($conf->engine == 'sqlite') {
$connection->getDriver()->registerFunction('regexp', 'Sqlite::regexp', 2);
} elseif ($conf->engine == 'postgre') {
dibi::addSubst('', '::');
}
if ($conf->profiler) {
$profiler = is_numeric($conf->profiler) || is_bool($conf->profiler) ? new DibiProfiler(array()) : new $conf->profiler();
$profiler->setFile(Environment::expand('%logDir%') . '/sql.log');
$connection->setProfiler($profiler);
}
}
示例9: setupHooks
protected static function setupHooks()
{
$db_config = Environment::getConfig('database');
define('TABLE_ACL', $db_config->tables->acl);
define('TABLE_PRIVILEGES', $db_config->tables->acl_privileges);
define('TABLE_ASSERTIONS', $db_config->tables->acl_assertions);
define('TABLE_RESOURCES', $db_config->tables->acl_resources);
define('TABLE_ROLES', $db_config->tables->acl_roles);
define('TABLE_USERS', $db_config->tables->users);
define('TABLE_USERS_ROLES', $db_config->tables->users_2_roles);
$acl_config = Environment::getConfig('acl');
define('ACL_RESOURCE', $acl_config->resource);
define('ACL_PRIVILEGE', $acl_config->privilege);
define('ACL_CACHING', $acl_config->cache);
define('ACL_PROG_MODE', $acl_config->programmer_mode);
}
示例10: createHttpRequestService
function createHttpRequestService()
{
$config = Environment::getConfig('httpRequest');
// params can be taken from config or command line if needed
$uri = new UriScript();
$uri->scheme = 'http';
$uri->port = Uri::$defaultPorts['http'];
$uri->host = $config->host;
$uri->path = $config->path;
// $uri->path = '/';
$uri->canonicalize();
$uri->path = String::fixEncoding($uri->path);
$uri->scriptPath = '/';
$req = new HttpRequest();
$req->setUri($uri);
return $req;
}
示例11: okClicked
public function okClicked($button)
{
$arr = $button->getForm()->getValues();
$username = $arr['userName'];
$password = $arr['password'];
$user = Environment::getUser();
// zaregistrujeme autentizační handler
$credits = (array) Environment::getConfig('admin');
$user->setAuthenticationHandler(new SimpleAuthenticator(array($credits['username'] => $credits['password'])));
try {
// pokusíme se přihlásit uživatele...
$user->authenticate($username, $password);
$this->redirect(':Admin:Default:');
} catch (AuthenticationException $e) {
$this->error = $e->getMessage();
$this->redirect('this');
}
}
示例12: run
public function run()
{
$this->cache = Environment::getCache('Application');
$modules = Environment::getConfig('modules');
if (!empty($modules)) {
foreach ($modules as $module) {
$this->loadModule($module);
}
}
$this->setupRouter();
// $this->setupHooks();
// Requires database connection
$this->onRequest[] = array($this, 'setupPermission');
// ...
// Run the application!
parent::run();
$this->cache->release();
}
示例13: factory
/**
* Autoloader factory.
* @return Acl
*/
public static function factory()
{
$expire = 24 * 60 * 60;
// 1 den
$driver = Environment::getConfig('database')->driver;
try {
$key = 'acl';
$cache = Environment::getCache('application/acl');
if (isset($cache[$key])) {
// serving from cache
return $cache[$key];
} else {
$acl = new self();
$cache->save($key, $acl, array('expire' => $expire, 'tags' => array('system', 'acl')));
return $acl;
}
} catch (Exception $e) {
$acl = new self();
//$cache->save($key, $acl, array('expire' => $expire));
return $acl;
}
}
示例14: authenticate
public function authenticate(array $credentials)
{
$login = $credentials['username'];
$password = $this->phash($credentials['password']);
$super_admin = Environment::getConfig('admin');
if ($login == $super_admin['login']) {
if ($password == $super_admin['password']) {
$super_admin_info['name'] = 'super admin';
$row = new DibiRow($super_admin_info);
} else {
throw new AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
}
} else {
$row = db::select('*')->from('[:admin:users]')->where('login = %s', $login)->fetch();
if (!$row) {
throw new AuthenticationException("Login '{$login}' not found.", self::IDENTITY_NOT_FOUND);
}
if ($row->password !== $password) {
throw new AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
}
}
return new Identity($row->name);
}
示例15: createService
<h1>Nette\Environment config test</h1>
<pre>
<?php
require_once '../../Nette/loader.php';
/*use Nette\Debug;*/
/*use Nette\Environment;*/
class Factory
{
static function createService($options)
{
Debug::dump(__METHOD__);
Debug::dump($options);
return (object) NULL;
}
}
echo "Loading config:\n";
Environment::setName(Environment::PRODUCTION);
Environment::loadConfig('config.ini');
echo "Variable foo:\n";
Debug::dump(Environment::getVariable('foo'));
echo "Constant HELLO_WORLD:\n";
Debug::dump(constant('HELLO_WORLD'));
echo "php.ini config:\n";
Debug::dump(Environment::getConfig('php'));
echo "Database config:\n";
Debug::dump(Environment::getConfig('database'));
echo "is production mode?\n";
Debug::dump(Environment::isProduction());