本文整理汇总了PHP中Zend_Config_Writer_Ini::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Config_Writer_Ini::render方法的具体用法?PHP Zend_Config_Writer_Ini::render怎么用?PHP Zend_Config_Writer_Ini::render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Config_Writer_Ini
的用法示例。
在下文中一共展示了Zend_Config_Writer_Ini::render方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dosetupAction
public function dosetupAction()
{
$this->view->headTitle('Configuration');
$_user_config_file = APPLICATION_PATH . '/configs/config.ini';
// Create the config ini from session
$setup_session = new Zend_Session_Namespace('gd_setup_session');
if (!$setup_session->complete) {
$config = new Zend_Config(array(), true);
$config->database = array();
$config->database->adapter = "PDO_MYSQL";
$config->database->host = $setup_session->database->host;
$config->database->username = $setup_session->database->username;
$config->database->password = $setup_session->database->password;
$config->database->dbname = $setup_session->database->dbname;
$writer_opts = array('config' => $config, 'filename' => $_user_config_file);
$writer = new Zend_Config_Writer_Ini($writer_opts);
try {
$writer->write();
} catch (Exception $ex) {
if (strpos($ex->getMessage(), 'Could not write to file') !== false) {
$setup_session->ini_string = $writer->render();
}
}
// Load the database manually
Zend_Db_Table::setDefaultAdapter(Zend_Db::factory($config->database->adapter, $config->database->toArray()));
// Run the appropriate database setup script
$db_adm = new GD_Db_Admin($config->database->host, $config->database->username, $config->database->password, $config->database->dbname);
$db_adm->installDatabase();
// Set the other config values into database
GD_Config::set("language", $setup_session->language ? $setup_session->language : "english");
GD_Config::set("setup_complete", "1");
GD_Config::set("cryptkey", md5(microtime() . $setup_session->admin->username . $setup_session->admin->password));
GD_Config::set("install_date", date("d/m/Y H:i:s"));
// Create the first user in the database
$userMapper = new GD_Model_UsersMapper();
$crypt = new GD_Crypt();
$user = new GD_Model_User();
$user->setName($setup_session->admin->username)->setPassword($crypt->makeHash($setup_session->admin->password))->setDateAdded(date('Y-m-d H:i:s'))->setAdmin(1)->enableUser();
$userMapper->save($user);
// Setup the SSH keypair
$ssh_key = new GD_Model_SSHKey();
$ssh_key->setSSHKeyTypesId(1);
$ssh_key->generateKeyPair();
//$ssh_key->setId(1);
$ssh_keys_map = new GD_Model_SSHKeysMapper();
$ssh_key_id = $ssh_keys_map->save($ssh_key);
GD_Config::set("ssh_key_id", $ssh_key_id);
$setup_session->complete = true;
}
if (isset($setup_session->ini_string)) {
$this->view->ini = $setup_session->ini_string;
} else {
$this->_redirect("/setup/complete");
}
}
示例2: getConfigContent
function getConfigContent($db_type = "", $db_host = "", $db_user = "", $db_pass = "", $db_database = "", $db_schema = "", $db_encoding = "", $adminuser, $adminpass, &$config)
{
// set base path
$config->base->base_path = $this->base_path;
// set db connection params
$config->db->adapter = $db_type;
$config->db->params->host = $db_host;
$config->db->params->username = $db_user;
$config->db->params->password = $db_pass;
$config->db->params->dbname = $db_database;
$config->db->encoding = $db_encoding;
$config->db->schema = $db_schema;
// init writer
$writer = new Zend_Config_Writer_Ini(array('config' => $config));
return $writer->render();
}