Ejemplo n.º 1
0
Archivo: Config.php Proyecto: wuxw/YYF
 /**
  * 获取私密配置
  * @method secret
  * @param  [string] $name     [配置名]
  * @param  [string] $key 		[键值]
  * @return [midex]          [description]
  * @author NewFuture
  * @example
  *  Config::getSecrect('encrypt') 获取取私密配置中的encrypt所有配置
  *  Config::getSecrect('encrypt','key') 获取取私密配置中的encrypt配置的secret值
  */
 public static function getSecret($name = '', $key = null)
 {
     if ($path = self::getConfig()->get('secret_config_path')) {
         $secretConfig = new Yaf_Config_Ini($path, $name);
         return $key ? $secretConfig->get($key) : $secretConfig->toArray();
     }
 }
Ejemplo n.º 2
0
 protected function __construct()
 {
     $config = new Yaf_Config_Ini(APP_PATH . '/conf/application.ini');
     $dbConfig = $config->get('product')->db;
     $dsn = "mysql:host={$dbConfig->host};port={$dbConfig->prot};charset={$dbConfig->charset};dbname={$dbConfig->name}";
     $this->_pdo = new PDO($dsn, $dbConfig->user, $dbConfig->pwd);
 }
Ejemplo n.º 3
0
 /**
  * @runInSeparateProcess
  */
 public function testCase014()
 {
     $app = new Yaf_Application(dirname(__FILE__) . "/_files/simple.ini", 'product');
     $config = new Yaf_Config_Ini(dirname(__FILE__) . "/_files/simple.ini", 'product');
     $this->assertEquals($config->toArray(), $app->getConfig()->toArray());
     $this->assertEquals(APPLICATION_PATH . '/application', $app->getAppDirectory());
     $this->assertEquals(array('Index'), $app->getModules());
 }
Ejemplo n.º 4
0
 /**
  * 获取一个数据库连接 数据库必须在conf/mysql.ini下有配置节信息
  * 
  * @param string $dbname 数据库名
  * @return Ap_DB_Mysqli
  */
 private function getDBConn($dbname)
 {
     $file = APP_PATH . '/conf/mysql.ini';
     if (!file_exists($file)) {
         $file = APP_PATH . '/conf/mysql.ini';
     }
     $ini = new Yaf_Config_Ini($file);
     $conf = $ini->get($dbname);
     $this->db = DB_Mysqli::getInstance($conf['host'], $conf['user'], $conf['pass'], $conf['db'], $conf['port']);
 }
Ejemplo n.º 5
0
 /**
  * 获取url.ini配置的地址
  * 
  * @param string $name
  * @return string 
  */
 public static function getUrlIniConfig($name)
 {
     static $config = null;
     if ($config === null) {
         $config = new Yaf_Config_Ini(APPLICATION_PATH . '/conf/url.ini', ini_get('yaf.environ'));
     }
     $urlConf = $config->get('config.url');
     if ($urlConf === null) {
         throw new Exception("config.url is not exist");
     }
     if ($urlConf[$name] === null) {
         throw new Exception("config.url" . $name . " is not exist");
     }
     return $urlConf[$name];
 }
Ejemplo n.º 6
0
 public function init()
 {
     $config = new \Yaf_Config_Ini(APP_PATH . '/conf/application.ini', 'test');
     $type = $config->get('database')->type;
     $host = $config->get('database')->host;
     $port = $config->get('database')->port;
     $username = $config->get('database')->username;
     $password = $config->get('database')->password;
     $databaseName = $config->get('database')->databaseName;
     $dsn = $type . ':' . 'dbname=' . $databaseName . ';host=' . $host;
     $this->connection = new Connection($dsn, $username, $password);
 }
Ejemplo n.º 7
0
 public function testCase018()
 {
     $config = new Yaf_Config_Ini(dirname(__FILE__) . '/_files/testCase018.ini', 'base');
     $iniAsArray = array('application' => array('directory' => APPLICATION_PATH . '/applcation'), 'name' => 'base', 'array' => array(1 => '1', 'name' => 'name'), 5 => '5', 'routes' => array('regex' => array('type' => 'regex', 'match' => '^/ap/(.*)', 'route' => array('controller' => 'Index', 'action' => 'action'), 'map' => array(0 => 'name', 1 => 'name', 2 => 'value')), 'simple' => array('type' => 'simple', 'controller' => 'c', 'module' => 'm', 'action' => 'a'), 'supervar' => array('type' => 'supervar', 'varname' => 'c'), 'rewrite' => array('type' => 'rewrite', 'match' => '/yaf/:name/:value', 'route' => array('controller' => 'Index', 'action' => 'action'))));
     $this->assertEquals($iniAsArray, $config->toArray());
 }
Ejemplo n.º 8
0
 public function _initView(Yaf_Dispatcher $dispatcher)
 {
     $config = new Yaf_Config_Ini(APP_PATH . '/conf/smarty.ini', 'product');
     $smarty = new Smarty_Adapter(APP_PATH . "/application/views/", $config->toArray());
     Yaf_Dispatcher::getInstance()->setView($smarty);
 }